func (client *AutoRestValidationTestClient) validationOfMethodParametersHandleError(resp *http.Response) error {
	body, err := runtime.Payload(resp)
	if err != nil {
		return runtime.NewResponseError(err, resp)
	}
	errType := Error{raw: string(body)}
	if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil {
		return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp)
	}
	return runtime.NewResponseError(&errType, resp)
}
validationOfMethodParametersHandleError handles the ValidationOfMethodParameters error response.
package validationgroup
import (
	"context"
	"errors"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
	"net/http"
	"net/url"
	"strconv"
	"strings"
)
type AutoRestValidationTestClient struct {
	con            *Connection
	subscriptionID string
}
func NewAutoRestValidationTestClient(con *Connection, subscriptionID string) *AutoRestValidationTestClient {
	return &AutoRestValidationTestClient{con: con, subscriptionID: subscriptionID}
}
func (client *AutoRestValidationTestClient) GetWithConstantInPath(ctx context.Context, options *AutoRestValidationTestGetWithConstantInPathOptions) (AutoRestValidationTestGetWithConstantInPathResponse, error) {
	req, err := client.getWithConstantInPathCreateRequest(ctx, options)
	if err != nil {
		return AutoRestValidationTestGetWithConstantInPathResponse{}, err
	}
	resp, err := client.con.Pipeline().Do(req)
	if err != nil {
		return AutoRestValidationTestGetWithConstantInPathResponse{}, err
	}
	if !runtime.HasStatusCode(resp, http.StatusOK) {
		return AutoRestValidationTestGetWithConstantInPathResponse{}, client.getWithConstantInPathHandleError(resp)
	}
	return AutoRestValidationTestGetWithConstantInPathResponse{RawResponse: resp}, nil
}
func (client *AutoRestValidationTestClient) getWithConstantInPathCreateRequest(ctx context.Context, options *AutoRestValidationTestGetWithConstantInPathOptions) (*policy.Request, error) {
	urlPath := "/validation/constantsInPath/{constantParam}/value"
	urlPath = strings.ReplaceAll(urlPath, "{constantParam}", url.PathEscape("constant"))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	return req, nil
}
func (client *AutoRestValidationTestClient) getWithConstantInPathHandleError(resp *http.Response) error {
	body, err := runtime.Payload(resp)
	if err != nil {
		return runtime.NewResponseError(err, resp)
	}
	if len(body) == 0 {
		return runtime.NewResponseError(errors.New(resp.Status), resp)
	}
	return runtime.NewResponseError(errors.New(string(body)), resp)
}
func (client *AutoRestValidationTestClient) PostWithConstantInBody(ctx context.Context, options *AutoRestValidationTestPostWithConstantInBodyOptions) (AutoRestValidationTestPostWithConstantInBodyResponse, error) {
	req, err := client.postWithConstantInBodyCreateRequest(ctx, options)
	if err != nil {
		return AutoRestValidationTestPostWithConstantInBodyResponse{}, err
	}
	resp, err := client.con.Pipeline().Do(req)
	if err != nil {
		return AutoRestValidationTestPostWithConstantInBodyResponse{}, err
	}
	if !runtime.HasStatusCode(resp, http.StatusOK) {
		return AutoRestValidationTestPostWithConstantInBodyResponse{}, client.postWithConstantInBodyHandleError(resp)
	}
	return client.postWithConstantInBodyHandleResponse(resp)
}
func (client *AutoRestValidationTestClient) postWithConstantInBodyCreateRequest(ctx context.Context, options *AutoRestValidationTestPostWithConstantInBodyOptions) (*policy.Request, error) {
	urlPath := "/validation/constantsInPath/{constantParam}/value"
	urlPath = strings.ReplaceAll(urlPath, "{constantParam}", url.PathEscape("constant"))
	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.con.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	req.Raw().Header.Set("Accept", "application/json")
	if options != nil && options.Body != nil {
		return req, runtime.MarshalAsJSON(req, *options.Body)
	}
	return req, nil
}
func (client *AutoRestValidationTestClient) postWithConstantInBodyHandleResponse(resp *http.Response) (AutoRestValidationTestPostWithConstantInBodyResponse, error) {
	result := AutoRestValidationTestPostWithConstantInBodyResponse{RawResponse: resp}
	if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil {
		return AutoRestValidationTestPostWithConstantInBodyResponse{}, runtime.NewResponseError(err, resp)
	}
	return result, nil
}
func (client *AutoRestValidationTestClient) postWithConstantInBodyHandleError(resp *http.Response) error {
	body, err := runtime.Payload(resp)
	if err != nil {
		return runtime.NewResponseError(err, resp)
	}
	if len(body) == 0 {
		return runtime.NewResponseError(errors.New(resp.Status), resp)
	}
	return runtime.NewResponseError(errors.New(string(body)), resp)
}
func (client *AutoRestValidationTestClient) ValidationOfBody(ctx context.Context, resourceGroupName string, id int32, options *AutoRestValidationTestValidationOfBodyOptions) (AutoRestValidationTestValidationOfBodyResponse, error) {
	req, err := client.validationOfBodyCreateRequest(ctx, resourceGroupName, id, options)
	if err != nil {
		return AutoRestValidationTestValidationOfBodyResponse{}, err
	}
	resp, err := client.con.Pipeline().Do(req)
	if err != nil {
		return AutoRestValidationTestValidationOfBodyResponse{}, err
	}
	if !runtime.HasStatusCode(resp, http.StatusOK) {
		return AutoRestValidationTestValidationOfBodyResponse{}, client.validationOfBodyHandleError(resp)
	}
	return client.validationOfBodyHandleResponse(resp)
}
func (client *AutoRestValidationTestClient) validationOfBodyCreateRequest(ctx context.Context, resourceGroupName string, id int32, options *AutoRestValidationTestValidationOfBodyOptions) (*policy.Request, error) {
	urlPath := "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if resourceGroupName == "" {
		return nil, errors.New("parameter resourceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
	urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(strconv.FormatInt(int64(id), 10)))
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.con.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("apiVersion", "1.0.0")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header.Set("Accept", "application/json")
	if options != nil && options.Body != nil {
		return req, runtime.MarshalAsJSON(req, *options.Body)
	}
	return req, nil
}
func (client *AutoRestValidationTestClient) validationOfBodyHandleResponse(resp *http.Response) (AutoRestValidationTestValidationOfBodyResponse, error) {
	result := AutoRestValidationTestValidationOfBodyResponse{RawResponse: resp}
	if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil {
		return AutoRestValidationTestValidationOfBodyResponse{}, runtime.NewResponseError(err, resp)
	}
	return result, nil
}
func (client *AutoRestValidationTestClient) validationOfBodyHandleError(resp *http.Response) error {
	body, err := runtime.Payload(resp)
	if err != nil {
		return runtime.NewResponseError(err, resp)
	}
	errType := Error{raw: string(body)}
	if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil {
		return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp)
	}
	return runtime.NewResponseError(&errType, resp)
}
func (client *AutoRestValidationTestClient) ValidationOfMethodParameters(ctx context.Context, resourceGroupName string, id int32, options *AutoRestValidationTestValidationOfMethodParametersOptions) (AutoRestValidationTestValidationOfMethodParametersResponse, error) {
	req, err := client.validationOfMethodParametersCreateRequest(ctx, resourceGroupName, id, options)
	if err != nil {
		return AutoRestValidationTestValidationOfMethodParametersResponse{}, err
	}
	resp, err := client.con.Pipeline().Do(req)
	if err != nil {
		return AutoRestValidationTestValidationOfMethodParametersResponse{}, err
	}
	if !runtime.HasStatusCode(resp, http.StatusOK) {
		return AutoRestValidationTestValidationOfMethodParametersResponse{}, client.validationOfMethodParametersHandleError(resp)
	}
	return client.validationOfMethodParametersHandleResponse(resp)
}
func (client *AutoRestValidationTestClient) validationOfMethodParametersCreateRequest(ctx context.Context, resourceGroupName string, id int32, options *AutoRestValidationTestValidationOfMethodParametersOptions) (*policy.Request, error) {
	urlPath := "/fakepath/{subscriptionId}/{resourceGroupName}/{id}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if resourceGroupName == "" {
		return nil, errors.New("parameter resourceGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
	urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(strconv.FormatInt(int64(id), 10)))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("apiVersion", "1.0.0")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header.Set("Accept", "application/json")
	return req, nil
}
func (client *AutoRestValidationTestClient) validationOfMethodParametersHandleResponse(resp *http.Response) (AutoRestValidationTestValidationOfMethodParametersResponse, error) {
	result := AutoRestValidationTestValidationOfMethodParametersResponse{RawResponse: resp}
	if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil {
		return AutoRestValidationTestValidationOfMethodParametersResponse{}, runtime.NewResponseError(err, resp)
	}
	return result, nil
}