// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

package armpolicy

import (
	"context"
	"errors"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
	"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"
)

// SetDefinitionVersionsClient contains the methods for the PolicySetDefinitionVersions group.
// Don't use this type directly, use NewSetDefinitionVersionsClient() instead.
type SetDefinitionVersionsClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient with the specified values.
//   - subscriptionID - The ID of the target subscription. The value must be an UUID.
//   - credential - used to authorize requests. Usually a credential from azidentity.
//   - options - pass nil to accept the default values.
func NewSetDefinitionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionVersionsClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &SetDefinitionVersionsClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// CreateOrUpdate - This operation creates or updates a policy set definition version in the given subscription with the given
// name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - parameters - The policy set definition properties.
//   - options - SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate
//     method.
func (client *SetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.CreateOrUpdate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.createOrUpdateCreateRequest(ctx, policySetDefinitionName, policyDefinitionVersion, parameters, options)
	if err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err
	}
	resp, err := client.createOrUpdateHandleResponse(httpResp)
	return resp, err
}

// createOrUpdateCreateRequest creates the CreateOrUpdate request.
func (client *SetDefinitionVersionsClient) createOrUpdateCreateRequest(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, _ *SetDefinitionVersionsClientCreateOrUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
		return nil, err
	}
	return req, nil
}

// createOrUpdateHandleResponse handles the CreateOrUpdate response.
func (client *SetDefinitionVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) {
	result := SetDefinitionVersionsClientCreateOrUpdateResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err
	}
	return result, nil
}

// CreateOrUpdateAtManagementGroup - This operation creates or updates a policy set definition version in the given management
// group with the given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - managementGroupName - The name of the management group. The name is case insensitive.
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - parameters - The policy set definition version properties.
//   - options - SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup
//     method.
func (client *SetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupName, policySetDefinitionName, policyDefinitionVersion, parameters, options)
	if err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err
	}
	resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp)
	return resp, err
}

// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request.
func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, parameters SetDefinitionVersion, _ *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if managementGroupName == "" {
		return nil, errors.New("parameter managementGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, parameters); err != nil {
		return nil, err
	}
	return req, nil
}

// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response.
func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) {
	result := SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil {
		return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err
	}
	return result, nil
}

// Delete - This operation deletes the policy set definition version in the given subscription with the given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - options - SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete
//     method.
func (client *SetDefinitionVersionsClient) Delete(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.Delete"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.deleteCreateRequest(ctx, policySetDefinitionName, policyDefinitionVersion, options)
	if err != nil {
		return SetDefinitionVersionsClientDeleteResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientDeleteResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientDeleteResponse{}, err
	}
	return SetDefinitionVersionsClientDeleteResponse{}, nil
}

// deleteCreateRequest creates the Delete request.
func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, _ *SetDefinitionVersionsClientDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// DeleteAtManagementGroup - This operation deletes the policy set definition version in the given management group with the
// given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - managementGroupName - The name of the management group. The name is case insensitive.
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - options - SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup
//     method.
func (client *SetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.DeleteAtManagementGroup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupName, policySetDefinitionName, policyDefinitionVersion, options)
	if err != nil {
		return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err
	}
	return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, nil
}

// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request.
func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, _ *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if managementGroupName == "" {
		return nil, errors.New("parameter managementGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// Get - This operation retrieves the policy set definition version in the given subscription with the given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - options - SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get
//     method.
func (client *SetDefinitionVersionsClient) Get(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.Get"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getCreateRequest(ctx, policySetDefinitionName, policyDefinitionVersion, options)
	if err != nil {
		return SetDefinitionVersionsClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *SetDefinitionVersionsClient) getCreateRequest(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getHandleResponse handles the Get response.
func (client *SetDefinitionVersionsClient) getHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetResponse, error) {
	result := SetDefinitionVersionsClientGetResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil {
		return SetDefinitionVersionsClientGetResponse{}, err
	}
	return result, nil
}

// GetAtManagementGroup - This operation retrieves the policy set definition version in the given management group with the
// given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - managementGroupName - The name of the management group. The name is case insensitive.
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - options - SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup
//     method.
func (client *SetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.GetAtManagementGroup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupName, policySetDefinitionName, policyDefinitionVersion, options)
	if err != nil {
		return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err
	}
	resp, err := client.getAtManagementGroupHandleResponse(httpResp)
	return resp, err
}

// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request.
func (client *SetDefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if managementGroupName == "" {
		return nil, errors.New("parameter managementGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response.
func (client *SetDefinitionVersionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) {
	result := SetDefinitionVersionsClientGetAtManagementGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil {
		return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err
	}
	return result, nil
}

// GetBuiltIn - This operation retrieves the built-in policy set definition version with the given name and version.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y
//     is the minor version number, and z is the patch number
//   - options - SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn
//     method.
func (client *SetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.GetBuiltIn"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.getBuiltInCreateRequest(ctx, policySetDefinitionName, policyDefinitionVersion, options)
	if err != nil {
		return SetDefinitionVersionsClientGetBuiltInResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientGetBuiltInResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientGetBuiltInResponse{}, err
	}
	resp, err := client.getBuiltInHandleResponse(httpResp)
	return resp, err
}

// getBuiltInCreateRequest creates the GetBuiltIn request.
func (client *SetDefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}"
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	if policyDefinitionVersion == "" {
		return nil, errors.New("parameter policyDefinitionVersion cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(policyDefinitionVersion))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// getBuiltInHandleResponse handles the GetBuiltIn response.
func (client *SetDefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetBuiltInResponse, error) {
	result := SetDefinitionVersionsClientGetBuiltInResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil {
		return SetDefinitionVersionsClientGetBuiltInResponse{}, err
	}
	return result, nil
}

// NewListPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager
//     method.
func (client *SetDefinitionVersionsClient) NewListPager(policySetDefinitionName string, options *SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse] {
	return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListResponse]{
		More: func(page SetDefinitionVersionsClientListResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListResponse) (SetDefinitionVersionsClientListResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListPager")
			nextLink := ""
			if page != nil {
				nextLink = *page.NextLink
			}
			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
				return client.listCreateRequest(ctx, policySetDefinitionName, options)
			}, nil)
			if err != nil {
				return SetDefinitionVersionsClientListResponse{}, err
			}
			return client.listHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listCreateRequest creates the List request.
func (client *SetDefinitionVersionsClient) listCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionVersionsClientListOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	if options != nil && options.Top != nil {
		reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listHandleResponse handles the List response.
func (client *SetDefinitionVersionsClient) listHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListResponse, error) {
	result := SetDefinitionVersionsClientListResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListResponse{}, err
	}
	return result, nil
}

// ListAll - This operation lists all the policy set definition versions for all policy set definitions within a subscription.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll
//     method.
func (client *SetDefinitionVersionsClient) ListAll(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.ListAll"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.listAllCreateRequest(ctx, options)
	if err != nil {
		return SetDefinitionVersionsClientListAllResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientListAllResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientListAllResponse{}, err
	}
	resp, err := client.listAllHandleResponse(httpResp)
	return resp, err
}

// listAllCreateRequest creates the ListAll request.
func (client *SetDefinitionVersionsClient) listAllCreateRequest(ctx context.Context, _ *SetDefinitionVersionsClientListAllOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listAllHandleResponse handles the ListAll response.
func (client *SetDefinitionVersionsClient) listAllHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllResponse, error) {
	result := SetDefinitionVersionsClientListAllResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListAllResponse{}, err
	}
	return result, nil
}

// ListAllAtManagementGroup - This operation lists all the policy set definition versions for all policy set definitions at
// the management group scope.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - managementGroupName - The name of the management group. The name is case insensitive.
//   - options - SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup
//     method.
func (client *SetDefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.ListAllAtManagementGroup"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.listAllAtManagementGroupCreateRequest(ctx, managementGroupName, options)
	if err != nil {
		return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err
	}
	resp, err := client.listAllAtManagementGroupHandleResponse(httpResp)
	return resp, err
}

// listAllAtManagementGroupCreateRequest creates the ListAllAtManagementGroup request.
func (client *SetDefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, _ *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions"
	if managementGroupName == "" {
		return nil, errors.New("parameter managementGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listAllAtManagementGroupHandleResponse handles the ListAllAtManagementGroup response.
func (client *SetDefinitionVersionsClient) listAllAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) {
	result := SetDefinitionVersionsClientListAllAtManagementGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err
	}
	return result, nil
}

// ListAllBuiltins - This operation lists all the built-in policy set definition versions for all built-in policy set definitions.
// If the operation fails it returns an *azcore.ResponseError type.
//
// Generated from API version 2023-04-01
//   - options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins
//     method.
func (client *SetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) {
	var err error
	const operationName = "SetDefinitionVersionsClient.ListAllBuiltins"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.listAllBuiltinsCreateRequest(ctx, options)
	if err != nil {
		return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err
	}
	resp, err := client.listAllBuiltinsHandleResponse(httpResp)
	return resp, err
}

// listAllBuiltinsCreateRequest creates the ListAllBuiltins request.
func (client *SetDefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context.Context, _ *SetDefinitionVersionsClientListAllBuiltinsOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions"
	req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listAllBuiltinsHandleResponse handles the ListAllBuiltins response.
func (client *SetDefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) {
	result := SetDefinitionVersionsClientListAllBuiltinsResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err
	}
	return result, nil
}

// NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definition versions for the given
// built-in policy set definition.
//
// Generated from API version 2023-04-01
//   - policySetDefinitionName - The name of the policy set definition.
//   - options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager
//     method.
func (client *SetDefinitionVersionsClient) NewListBuiltInPager(policySetDefinitionName string, options *SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse] {
	return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListBuiltInResponse]{
		More: func(page SetDefinitionVersionsClientListBuiltInResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListBuiltInResponse) (SetDefinitionVersionsClientListBuiltInResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListBuiltInPager")
			nextLink := ""
			if page != nil {
				nextLink = *page.NextLink
			}
			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
				return client.listBuiltInCreateRequest(ctx, policySetDefinitionName, options)
			}, nil)
			if err != nil {
				return SetDefinitionVersionsClientListBuiltInResponse{}, err
			}
			return client.listBuiltInHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listBuiltInCreateRequest creates the ListBuiltIn request.
func (client *SetDefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions"
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	if options != nil && options.Top != nil {
		reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listBuiltInHandleResponse handles the ListBuiltIn response.
func (client *SetDefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListBuiltInResponse, error) {
	result := SetDefinitionVersionsClientListBuiltInResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListBuiltInResponse{}, err
	}
	return result, nil
}

// NewListByManagementGroupPager - This operation retrieves a list of all the policy set definition versions for the given
// policy set definition in a given management group.
//
// Generated from API version 2023-04-01
//   - managementGroupName - The name of the management group. The name is case insensitive.
//   - policySetDefinitionName - The name of the policy set definition.
//   - options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager
//     method.
func (client *SetDefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, policySetDefinitionName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse] {
	return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListByManagementGroupResponse]{
		More: func(page SetDefinitionVersionsClientListByManagementGroupResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListByManagementGroupResponse) (SetDefinitionVersionsClientListByManagementGroupResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListByManagementGroupPager")
			nextLink := ""
			if page != nil {
				nextLink = *page.NextLink
			}
			resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) {
				return client.listByManagementGroupCreateRequest(ctx, managementGroupName, policySetDefinitionName, options)
			}, nil)
			if err != nil {
				return SetDefinitionVersionsClientListByManagementGroupResponse{}, err
			}
			return client.listByManagementGroupHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByManagementGroupCreateRequest creates the ListByManagementGroup request.
func (client *SetDefinitionVersionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, policySetDefinitionName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) (*policy.Request, error) {
	urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions"
	if managementGroupName == "" {
		return nil, errors.New("parameter managementGroupName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
	if policySetDefinitionName == "" {
		return nil, errors.New("parameter policySetDefinitionName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	if options != nil && options.Expand != nil {
		reqQP.Set("$expand", *options.Expand)
	}
	if options != nil && options.Top != nil {
		reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
	}
	reqQP.Set("api-version", "2023-04-01")
	req.Raw().URL.RawQuery = reqQP.Encode()
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listByManagementGroupHandleResponse handles the ListByManagementGroup response.
func (client *SetDefinitionVersionsClient) listByManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListByManagementGroupResponse, error) {
	result := SetDefinitionVersionsClientListByManagementGroupResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil {
		return SetDefinitionVersionsClientListByManagementGroupResponse{}, err
	}
	return result, nil
}
