// 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) Go Code Generator. DO NOT EDIT.

package armenclave

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"
	"strings"
)

// TransitHubClient - TransitHub Interface
// Don't use this type directly, use NewTransitHubClient() instead.
//
// Generated from API version 2026-03-01-preview
type TransitHubClient struct {
	internal       *arm.Client
	subscriptionID string
}

// NewTransitHubClient creates a new instance of TransitHubClient 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 - Contains optional client configuration. Pass nil to accept the default values.
func NewTransitHubClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TransitHubClient, error) {
	cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)
	if err != nil {
		return nil, err
	}
	client := &TransitHubClient{
		subscriptionID: subscriptionID,
		internal:       cl,
	}
	return client, nil
}

// BeginCreateOrUpdate - Create a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - communityName - The name of the communityResource Resource
//   - transitHubName - The name of the TransitHub Resource
//   - resource - Resource create parameters.
//   - options - TransitHubClientBeginCreateOrUpdateOptions contains the optional parameters for the TransitHubClient.BeginCreateOrUpdate
//     method.
func (client *TransitHubClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, options *TransitHubClientBeginCreateOrUpdateOptions) (*runtime.Poller[TransitHubClientCreateOrUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.createOrUpdate(ctx, resourceGroupName, communityName, transitHubName, resource, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientCreateOrUpdateResponse]{
			FinalStateVia: runtime.FinalStateViaAzureAsyncOp,
			Tracer:        client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientCreateOrUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// CreateOrUpdate - Create a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
func (client *TransitHubClient) createOrUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, options *TransitHubClientBeginCreateOrUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "TransitHubClient.BeginCreateOrUpdate"
	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, resourceGroupName, communityName, transitHubName, resource, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// createOrUpdateCreateRequest creates the CreateOrUpdate request.
func (client *TransitHubClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, _ *TransitHubClientBeginCreateOrUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}"
	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))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	if transitHubName == "" {
		return nil, errors.New("parameter transitHubName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName))
	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", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, resource); err != nil {
		return nil, err
	}
	return req, nil
}

// BeginDelete - Delete a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - communityName - The name of the communityResource Resource
//   - transitHubName - The name of the TransitHub Resource
//   - options - TransitHubClientBeginDeleteOptions contains the optional parameters for the TransitHubClient.BeginDelete method.
func (client *TransitHubClient) BeginDelete(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientBeginDeleteOptions) (*runtime.Poller[TransitHubClientDeleteResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.deleteOperation(ctx, resourceGroupName, communityName, transitHubName, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientDeleteResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Delete - Delete a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
func (client *TransitHubClient) deleteOperation(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientBeginDeleteOptions) (*http.Response, error) {
	var err error
	const operationName = "TransitHubClient.BeginDelete"
	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, resourceGroupName, communityName, transitHubName, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// deleteCreateRequest creates the Delete request.
func (client *TransitHubClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, _ *TransitHubClientBeginDeleteOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}"
	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))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	if transitHubName == "" {
		return nil, errors.New("parameter transitHubName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName))
	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", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	return req, nil
}

// Get - Get a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - communityName - The name of the communityResource Resource
//   - transitHubName - The name of the TransitHub Resource
//   - options - TransitHubClientGetOptions contains the optional parameters for the TransitHubClient.Get method.
func (client *TransitHubClient) Get(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientGetOptions) (TransitHubClientGetResponse, error) {
	var err error
	const operationName = "TransitHubClient.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, resourceGroupName, communityName, transitHubName, options)
	if err != nil {
		return TransitHubClientGetResponse{}, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return TransitHubClientGetResponse{}, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK) {
		err = runtime.NewResponseError(httpResp)
		return TransitHubClientGetResponse{}, err
	}
	resp, err := client.getHandleResponse(httpResp)
	return resp, err
}

// getCreateRequest creates the Get request.
func (client *TransitHubClient) getCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, _ *TransitHubClientGetOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}"
	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))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	if transitHubName == "" {
		return nil, errors.New("parameter transitHubName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

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

// NewListByCommunityResourcePager - List TransitHubResource resources by CommunityResource
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - communityName - The name of the communityResource Resource
//   - options - TransitHubClientListByCommunityResourceOptions contains the optional parameters for the TransitHubClient.NewListByCommunityResourcePager
//     method.
func (client *TransitHubClient) NewListByCommunityResourcePager(resourceGroupName string, communityName string, options *TransitHubClientListByCommunityResourceOptions) *runtime.Pager[TransitHubClientListByCommunityResourceResponse] {
	return runtime.NewPager(runtime.PagingHandler[TransitHubClientListByCommunityResourceResponse]{
		More: func(page TransitHubClientListByCommunityResourceResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *TransitHubClientListByCommunityResourceResponse) (TransitHubClientListByCommunityResourceResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransitHubClient.NewListByCommunityResourcePager")
			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.listByCommunityResourceCreateRequest(ctx, resourceGroupName, communityName, options)
			}, nil)
			if err != nil {
				return TransitHubClientListByCommunityResourceResponse{}, err
			}
			return client.listByCommunityResourceHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listByCommunityResourceCreateRequest creates the ListByCommunityResource request.
func (client *TransitHubClient) listByCommunityResourceCreateRequest(ctx context.Context, resourceGroupName string, communityName string, _ *TransitHubClientListByCommunityResourceOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs"
	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))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listByCommunityResourceHandleResponse handles the ListByCommunityResource response.
func (client *TransitHubClient) listByCommunityResourceHandleResponse(resp *http.Response) (TransitHubClientListByCommunityResourceResponse, error) {
	result := TransitHubClientListByCommunityResourceResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.TransitHubResourceListResult); err != nil {
		return TransitHubClientListByCommunityResourceResponse{}, err
	}
	return result, nil
}

// NewListBySubscriptionPager - List TransitHubResource resources by subscription ID
//   - communityName - The name of the communityResource Resource
//   - options - TransitHubClientListBySubscriptionOptions contains the optional parameters for the TransitHubClient.NewListBySubscriptionPager
//     method.
func (client *TransitHubClient) NewListBySubscriptionPager(communityName string, options *TransitHubClientListBySubscriptionOptions) *runtime.Pager[TransitHubClientListBySubscriptionResponse] {
	return runtime.NewPager(runtime.PagingHandler[TransitHubClientListBySubscriptionResponse]{
		More: func(page TransitHubClientListBySubscriptionResponse) bool {
			return page.NextLink != nil && len(*page.NextLink) > 0
		},
		Fetcher: func(ctx context.Context, page *TransitHubClientListBySubscriptionResponse) (TransitHubClientListBySubscriptionResponse, error) {
			ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransitHubClient.NewListBySubscriptionPager")
			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.listBySubscriptionCreateRequest(ctx, communityName, options)
			}, nil)
			if err != nil {
				return TransitHubClientListBySubscriptionResponse{}, err
			}
			return client.listBySubscriptionHandleResponse(resp)
		},
		Tracer: client.internal.Tracer(),
	})
}

// listBySubscriptionCreateRequest creates the ListBySubscription request.
func (client *TransitHubClient) listBySubscriptionCreateRequest(ctx context.Context, communityName string, _ *TransitHubClientListBySubscriptionOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs"
	if client.subscriptionID == "" {
		return nil, errors.New("parameter client.subscriptionID cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	return req, nil
}

// listBySubscriptionHandleResponse handles the ListBySubscription response.
func (client *TransitHubClient) listBySubscriptionHandleResponse(resp *http.Response) (TransitHubClientListBySubscriptionResponse, error) {
	result := TransitHubClientListBySubscriptionResponse{}
	if err := runtime.UnmarshalAsJSON(resp, &result.TransitHubResourceListResult); err != nil {
		return TransitHubClientListBySubscriptionResponse{}, err
	}
	return result, nil
}

// BeginUpdate - Update a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
//   - resourceGroupName - The name of the resource group. The name is case insensitive.
//   - communityName - The name of the communityResource Resource
//   - transitHubName - The name of the TransitHub Resource
//   - properties - The resource properties to be updated.
//   - options - TransitHubClientBeginUpdateOptions contains the optional parameters for the TransitHubClient.BeginUpdate method.
func (client *TransitHubClient) BeginUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, options *TransitHubClientBeginUpdateOptions) (*runtime.Poller[TransitHubClientUpdateResponse], error) {
	if options == nil || options.ResumeToken == "" {
		resp, err := client.update(ctx, resourceGroupName, communityName, transitHubName, properties, options)
		if err != nil {
			return nil, err
		}
		poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
		return poller, err
	} else {
		return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientUpdateResponse]{
			Tracer: client.internal.Tracer(),
		})
	}
}

// Update - Update a TransitHubResource
// If the operation fails it returns an *azcore.ResponseError type.
func (client *TransitHubClient) update(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, options *TransitHubClientBeginUpdateOptions) (*http.Response, error) {
	var err error
	const operationName = "TransitHubClient.BeginUpdate"
	ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName)
	ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil)
	defer func() { endSpan(err) }()
	req, err := client.updateCreateRequest(ctx, resourceGroupName, communityName, transitHubName, properties, options)
	if err != nil {
		return nil, err
	}
	httpResp, err := client.internal.Pipeline().Do(req)
	if err != nil {
		return nil, err
	}
	if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) {
		err = runtime.NewResponseError(httpResp)
		return nil, err
	}
	return httpResp, nil
}

// updateCreateRequest creates the Update request.
func (client *TransitHubClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, _ *TransitHubClientBeginUpdateOptions) (*policy.Request, error) {
	urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}"
	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))
	if communityName == "" {
		return nil, errors.New("parameter communityName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName))
	if transitHubName == "" {
		return nil, errors.New("parameter transitHubName cannot be empty")
	}
	urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName))
	req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))
	if err != nil {
		return nil, err
	}
	reqQP := req.Raw().URL.Query()
	reqQP.Set("api-version", version20260301Preview)
	req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")
	req.Raw().Header["Accept"] = []string{"application/json"}
	req.Raw().Header["Content-Type"] = []string{"application/json"}
	if err := runtime.MarshalAsJSON(req, properties); err != nil {
		return nil, err
	}
	return req, nil
}
