// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by the Google Gen AI SDK generator DO NOT EDIT.

package genai

import (
	"context"
	"fmt"
	"iter"
	"log"
	"net/http"
	"reflect"
	"sync"
)

func batchJobDestinationFromMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFileName := InternalGetValueByPath(fromObject, []string{"responsesFile"})
	if fromFileName != nil {
		InternalSetValueByPath(toObject, []string{"fileName"}, fromFileName)
	}

	fromInlinedResponses := InternalGetValueByPath(fromObject, []string{"inlinedResponses", "inlinedResponses"})
	if fromInlinedResponses != nil {
		fromInlinedResponses, err = applyConverterToSliceWithRoot(fromInlinedResponses.([]any), inlinedResponseFromMldev, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"inlinedResponses"}, fromInlinedResponses)
	}

	fromInlinedEmbedContentResponses := InternalGetValueByPath(fromObject, []string{"inlinedEmbedContentResponses", "inlinedResponses"})
	if fromInlinedEmbedContentResponses != nil {
		InternalSetValueByPath(toObject, []string{"inlinedEmbedContentResponses"}, fromInlinedEmbedContentResponses)
	}

	return toObject, nil
}

func batchJobDestinationFromVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFormat := InternalGetValueByPath(fromObject, []string{"predictionsFormat"})
	if fromFormat != nil {
		InternalSetValueByPath(toObject, []string{"format"}, fromFormat)
	}

	fromGcsUri := InternalGetValueByPath(fromObject, []string{"gcsDestination", "outputUriPrefix"})
	if fromGcsUri != nil {
		InternalSetValueByPath(toObject, []string{"gcsUri"}, fromGcsUri)
	}

	fromBigqueryUri := InternalGetValueByPath(fromObject, []string{"bigqueryDestination", "outputUri"})
	if fromBigqueryUri != nil {
		InternalSetValueByPath(toObject, []string{"bigqueryUri"}, fromBigqueryUri)
	}

	return toObject, nil
}

func batchJobDestinationToVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFormat := InternalGetValueByPath(fromObject, []string{"format"})
	if fromFormat != nil {
		InternalSetValueByPath(toObject, []string{"predictionsFormat"}, fromFormat)
	}

	fromGcsUri := InternalGetValueByPath(fromObject, []string{"gcsUri"})
	if fromGcsUri != nil {
		InternalSetValueByPath(toObject, []string{"gcsDestination", "outputUriPrefix"}, fromGcsUri)
	}

	fromBigqueryUri := InternalGetValueByPath(fromObject, []string{"bigqueryUri"})
	if fromBigqueryUri != nil {
		InternalSetValueByPath(toObject, []string{"bigqueryDestination", "outputUri"}, fromBigqueryUri)
	}

	if InternalGetValueByPath(fromObject, []string{"fileName"}) != nil {
		return nil, fmt.Errorf("fileName parameter is not supported in Vertex AI")
	}

	if InternalGetValueByPath(fromObject, []string{"inlinedResponses"}) != nil {
		return nil, fmt.Errorf("inlinedResponses parameter is not supported in Vertex AI")
	}

	if InternalGetValueByPath(fromObject, []string{"inlinedEmbedContentResponses"}) != nil {
		return nil, fmt.Errorf("inlinedEmbedContentResponses parameter is not supported in Vertex AI")
	}

	return toObject, nil
}

func batchJobFromMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		InternalSetValueByPath(toObject, []string{"name"}, fromName)
	}

	fromDisplayName := InternalGetValueByPath(fromObject, []string{"metadata", "displayName"})
	if fromDisplayName != nil {
		InternalSetValueByPath(toObject, []string{"displayName"}, fromDisplayName)
	}

	fromState := InternalGetValueByPath(fromObject, []string{"metadata", "state"})
	if fromState != nil {
		fromState, err = InternalTJobState(fromState)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"state"}, fromState)
	}

	fromCreateTime := InternalGetValueByPath(fromObject, []string{"metadata", "createTime"})
	if fromCreateTime != nil {
		InternalSetValueByPath(toObject, []string{"createTime"}, fromCreateTime)
	}

	fromEndTime := InternalGetValueByPath(fromObject, []string{"metadata", "endTime"})
	if fromEndTime != nil {
		InternalSetValueByPath(toObject, []string{"endTime"}, fromEndTime)
	}

	fromUpdateTime := InternalGetValueByPath(fromObject, []string{"metadata", "updateTime"})
	if fromUpdateTime != nil {
		InternalSetValueByPath(toObject, []string{"updateTime"}, fromUpdateTime)
	}

	fromModel := InternalGetValueByPath(fromObject, []string{"metadata", "model"})
	if fromModel != nil {
		InternalSetValueByPath(toObject, []string{"model"}, fromModel)
	}

	fromDest := InternalGetValueByPath(fromObject, []string{"metadata", "output"})
	if fromDest != nil {
		fromDest, err = InternalTRecvBatchJobDestination(fromDest)
		if err != nil {
			return nil, err
		}

		fromDest, err = batchJobDestinationFromMldev(fromDest.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"dest"}, fromDest)
	}

	return toObject, nil
}

func batchJobFromVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		InternalSetValueByPath(toObject, []string{"name"}, fromName)
	}

	fromDisplayName := InternalGetValueByPath(fromObject, []string{"displayName"})
	if fromDisplayName != nil {
		InternalSetValueByPath(toObject, []string{"displayName"}, fromDisplayName)
	}

	fromState := InternalGetValueByPath(fromObject, []string{"state"})
	if fromState != nil {
		fromState, err = InternalTJobState(fromState)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"state"}, fromState)
	}

	fromError := InternalGetValueByPath(fromObject, []string{"error"})
	if fromError != nil {
		InternalSetValueByPath(toObject, []string{"error"}, fromError)
	}

	fromCreateTime := InternalGetValueByPath(fromObject, []string{"createTime"})
	if fromCreateTime != nil {
		InternalSetValueByPath(toObject, []string{"createTime"}, fromCreateTime)
	}

	fromStartTime := InternalGetValueByPath(fromObject, []string{"startTime"})
	if fromStartTime != nil {
		InternalSetValueByPath(toObject, []string{"startTime"}, fromStartTime)
	}

	fromEndTime := InternalGetValueByPath(fromObject, []string{"endTime"})
	if fromEndTime != nil {
		InternalSetValueByPath(toObject, []string{"endTime"}, fromEndTime)
	}

	fromUpdateTime := InternalGetValueByPath(fromObject, []string{"updateTime"})
	if fromUpdateTime != nil {
		InternalSetValueByPath(toObject, []string{"updateTime"}, fromUpdateTime)
	}

	fromModel := InternalGetValueByPath(fromObject, []string{"model"})
	if fromModel != nil {
		InternalSetValueByPath(toObject, []string{"model"}, fromModel)
	}

	fromSrc := InternalGetValueByPath(fromObject, []string{"inputConfig"})
	if fromSrc != nil {
		fromSrc, err = batchJobSourceFromVertex(fromSrc.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"src"}, fromSrc)
	}

	fromDest := InternalGetValueByPath(fromObject, []string{"outputConfig"})
	if fromDest != nil {
		fromDest, err = InternalTRecvBatchJobDestination(fromDest)
		if err != nil {
			return nil, err
		}

		fromDest, err = batchJobDestinationFromVertex(fromDest.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"dest"}, fromDest)
	}

	fromCompletionStats := InternalGetValueByPath(fromObject, []string{"completionStats"})
	if fromCompletionStats != nil {
		InternalSetValueByPath(toObject, []string{"completionStats"}, fromCompletionStats)
	}

	return toObject, nil
}

func batchJobSourceFromVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFormat := InternalGetValueByPath(fromObject, []string{"instancesFormat"})
	if fromFormat != nil {
		InternalSetValueByPath(toObject, []string{"format"}, fromFormat)
	}

	fromGcsUri := InternalGetValueByPath(fromObject, []string{"gcsSource", "uris"})
	if fromGcsUri != nil {
		InternalSetValueByPath(toObject, []string{"gcsUri"}, fromGcsUri)
	}

	fromBigqueryUri := InternalGetValueByPath(fromObject, []string{"bigquerySource", "inputUri"})
	if fromBigqueryUri != nil {
		InternalSetValueByPath(toObject, []string{"bigqueryUri"}, fromBigqueryUri)
	}

	return toObject, nil
}

func batchJobSourceToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)
	if InternalGetValueByPath(fromObject, []string{"format"}) != nil {
		return nil, fmt.Errorf("format parameter is not supported in Gemini API")
	}

	if InternalGetValueByPath(fromObject, []string{"gcsUri"}) != nil {
		return nil, fmt.Errorf("gcsUri parameter is not supported in Gemini API")
	}

	if InternalGetValueByPath(fromObject, []string{"bigqueryUri"}) != nil {
		return nil, fmt.Errorf("bigqueryUri parameter is not supported in Gemini API")
	}

	fromFileName := InternalGetValueByPath(fromObject, []string{"fileName"})
	if fromFileName != nil {
		InternalSetValueByPath(toObject, []string{"fileName"}, fromFileName)
	}

	fromInlinedRequests := InternalGetValueByPath(fromObject, []string{"inlinedRequests"})
	if fromInlinedRequests != nil {
		fromInlinedRequests, err = applyConverterToSliceWithClientWithRoot(ac, fromInlinedRequests.([]any), inlinedRequestToMldev, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"requests", "requests"}, fromInlinedRequests)
	}

	return toObject, nil
}

func batchJobSourceToVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFormat := InternalGetValueByPath(fromObject, []string{"format"})
	if fromFormat != nil {
		InternalSetValueByPath(toObject, []string{"instancesFormat"}, fromFormat)
	}

	fromGcsUri := InternalGetValueByPath(fromObject, []string{"gcsUri"})
	if fromGcsUri != nil {
		InternalSetValueByPath(toObject, []string{"gcsSource", "uris"}, fromGcsUri)
	}

	fromBigqueryUri := InternalGetValueByPath(fromObject, []string{"bigqueryUri"})
	if fromBigqueryUri != nil {
		InternalSetValueByPath(toObject, []string{"bigquerySource", "inputUri"}, fromBigqueryUri)
	}

	if InternalGetValueByPath(fromObject, []string{"fileName"}) != nil {
		return nil, fmt.Errorf("fileName parameter is not supported in Vertex AI")
	}

	if InternalGetValueByPath(fromObject, []string{"inlinedRequests"}) != nil {
		return nil, fmt.Errorf("inlinedRequests parameter is not supported in Vertex AI")
	}

	return toObject, nil
}

func cancelBatchJobParametersToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func cancelBatchJobParametersToVertex(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func createBatchJobConfigToMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromDisplayName := InternalGetValueByPath(fromObject, []string{"displayName"})
	if fromDisplayName != nil {
		InternalSetValueByPath(parentObject, []string{"batch", "displayName"}, fromDisplayName)
	}

	if InternalGetValueByPath(fromObject, []string{"dest"}) != nil {
		return nil, fmt.Errorf("dest parameter is not supported in Gemini API")
	}

	fromWebhookConfig := InternalGetValueByPath(fromObject, []string{"webhookConfig"})
	if fromWebhookConfig != nil {
		InternalSetValueByPath(parentObject, []string{"batch", "webhookConfig"}, fromWebhookConfig)
	}

	return toObject, nil
}

func createBatchJobConfigToVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromDisplayName := InternalGetValueByPath(fromObject, []string{"displayName"})
	if fromDisplayName != nil {
		InternalSetValueByPath(parentObject, []string{"displayName"}, fromDisplayName)
	}

	fromDest := InternalGetValueByPath(fromObject, []string{"dest"})
	if fromDest != nil {
		fromDest, err = InternalTBatchJobDestination(fromDest)
		if err != nil {
			return nil, err
		}

		fromDest, err = batchJobDestinationToVertex(fromDest.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(parentObject, []string{"outputConfig"}, fromDest)
	}

	if InternalGetValueByPath(fromObject, []string{"webhookConfig"}) != nil {
		return nil, fmt.Errorf("webhookConfig parameter is not supported in Vertex AI")
	}

	return toObject, nil
}

func createBatchJobParametersToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromModel := InternalGetValueByPath(fromObject, []string{"model"})
	if fromModel != nil {
		fromModel, err = InternalTModel(ac, fromModel)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "model"}, fromModel)
	}

	fromSrc := InternalGetValueByPath(fromObject, []string{"src"})
	if fromSrc != nil {
		fromSrc, err = InternalTBatchJobSource(fromSrc)
		if err != nil {
			return nil, err
		}

		fromSrc, err = batchJobSourceToMldev(ac, fromSrc.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"batch", "inputConfig"}, fromSrc)
	}

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		_, err = createBatchJobConfigToMldev(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}
	}

	return toObject, nil
}

func createBatchJobParametersToVertex(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromModel := InternalGetValueByPath(fromObject, []string{"model"})
	if fromModel != nil {
		fromModel, err = InternalTModel(ac, fromModel)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"model"}, fromModel)
	}

	fromSrc := InternalGetValueByPath(fromObject, []string{"src"})
	if fromSrc != nil {
		fromSrc, err = InternalTBatchJobSource(fromSrc)
		if err != nil {
			return nil, err
		}

		fromSrc, err = batchJobSourceToVertex(fromSrc.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"inputConfig"}, fromSrc)
	}

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		_, err = createBatchJobConfigToVertex(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}
	}

	return toObject, nil
}

func createEmbeddingsBatchJobConfigToMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromDisplayName := InternalGetValueByPath(fromObject, []string{"displayName"})
	if fromDisplayName != nil {
		InternalSetValueByPath(parentObject, []string{"batch", "displayName"}, fromDisplayName)
	}

	return toObject, nil
}

func createEmbeddingsBatchJobParametersToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromModel := InternalGetValueByPath(fromObject, []string{"model"})
	if fromModel != nil {
		fromModel, err = InternalTModel(ac, fromModel)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "model"}, fromModel)
	}

	fromSrc := InternalGetValueByPath(fromObject, []string{"src"})
	if fromSrc != nil {
		fromSrc, err = embeddingsBatchJobSourceToMldev(ac, fromSrc.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"batch", "inputConfig"}, fromSrc)
	}

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		_, err = createEmbeddingsBatchJobConfigToMldev(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}
	}

	return toObject, nil
}

func deleteBatchJobParametersToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func deleteBatchJobParametersToVertex(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func deleteResourceJobFromMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromSdkHttpResponse := InternalGetValueByPath(fromObject, []string{"sdkHttpResponse"})
	if fromSdkHttpResponse != nil {
		InternalSetValueByPath(toObject, []string{"sdkHttpResponse"}, fromSdkHttpResponse)
	}

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		InternalSetValueByPath(toObject, []string{"name"}, fromName)
	}

	fromDone := InternalGetValueByPath(fromObject, []string{"done"})
	if fromDone != nil {
		InternalSetValueByPath(toObject, []string{"done"}, fromDone)
	}

	fromError := InternalGetValueByPath(fromObject, []string{"error"})
	if fromError != nil {
		InternalSetValueByPath(toObject, []string{"error"}, fromError)
	}

	return toObject, nil
}

func deleteResourceJobFromVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromSdkHttpResponse := InternalGetValueByPath(fromObject, []string{"sdkHttpResponse"})
	if fromSdkHttpResponse != nil {
		InternalSetValueByPath(toObject, []string{"sdkHttpResponse"}, fromSdkHttpResponse)
	}

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		InternalSetValueByPath(toObject, []string{"name"}, fromName)
	}

	fromDone := InternalGetValueByPath(fromObject, []string{"done"})
	if fromDone != nil {
		InternalSetValueByPath(toObject, []string{"done"}, fromDone)
	}

	fromError := InternalGetValueByPath(fromObject, []string{"error"})
	if fromError != nil {
		InternalSetValueByPath(toObject, []string{"error"}, fromError)
	}

	return toObject, nil
}

func embedContentBatchToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromContents := InternalGetValueByPath(fromObject, []string{"contents"})
	if fromContents != nil {
		fromContents, err = InternalTContentsForEmbed(ac, fromContents)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"requests[]", "request", "content"}, fromContents)
	}

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		fromConfig, err = embedContentConfigToMldev(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_self"}, fromConfig)
		moveValueByPath(toObject, map[string]string{"requests[].*": "requests[].request.*"})
	}

	return toObject, nil
}

func embeddingsBatchJobSourceToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromFileName := InternalGetValueByPath(fromObject, []string{"fileName"})
	if fromFileName != nil {
		InternalSetValueByPath(toObject, []string{"file_name"}, fromFileName)
	}

	fromInlinedRequests := InternalGetValueByPath(fromObject, []string{"inlinedRequests"})
	if fromInlinedRequests != nil {
		fromInlinedRequests, err = embedContentBatchToMldev(ac, fromInlinedRequests.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"requests"}, fromInlinedRequests)
	}

	return toObject, nil
}

func getBatchJobParametersToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func getBatchJobParametersToVertex(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromName := InternalGetValueByPath(fromObject, []string{"name"})
	if fromName != nil {
		fromName, err = InternalTBatchJobName(ac, fromName)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"_url", "name"}, fromName)
	}

	return toObject, nil
}

func inlinedRequestToMldev(ac *InternalAPIClient, fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromModel := InternalGetValueByPath(fromObject, []string{"model"})
	if fromModel != nil {
		fromModel, err = InternalTModel(ac, fromModel)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"request", "model"}, fromModel)
	}

	fromContents := InternalGetValueByPath(fromObject, []string{"contents"})
	if fromContents != nil {
		fromContents, err = InternalTContents(fromContents)
		if err != nil {
			return nil, err
		}

		fromContents, err = applyConverterToSliceWithRoot(fromContents.([]any), contentToMldev, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"request", "contents"}, fromContents)
	}

	fromMetadata := InternalGetValueByPath(fromObject, []string{"metadata"})
	if fromMetadata != nil {
		InternalSetValueByPath(toObject, []string{"metadata"}, fromMetadata)
	}

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		fromConfig, err = generateContentConfigToMldev(ac, fromConfig.(map[string]any), getValueByPathOrDefault(toObject, []string{"request"}, map[string]any{}).(map[string]any), rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"request", "generationConfig"}, fromConfig)
	}

	return toObject, nil
}

func inlinedResponseFromMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromResponse := InternalGetValueByPath(fromObject, []string{"response"})
	if fromResponse != nil {
		fromResponse, err = generateContentResponseFromMldev(fromResponse.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"response"}, fromResponse)
	}

	fromMetadata := InternalGetValueByPath(fromObject, []string{"metadata"})
	if fromMetadata != nil {
		InternalSetValueByPath(toObject, []string{"metadata"}, fromMetadata)
	}

	fromError := InternalGetValueByPath(fromObject, []string{"error"})
	if fromError != nil {
		InternalSetValueByPath(toObject, []string{"error"}, fromError)
	}

	return toObject, nil
}

func listBatchJobsConfigToMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromPageSize := InternalGetValueByPath(fromObject, []string{"pageSize"})
	if fromPageSize != nil {
		InternalSetValueByPath(parentObject, []string{"_query", "pageSize"}, fromPageSize)
	}

	fromPageToken := InternalGetValueByPath(fromObject, []string{"pageToken"})
	if fromPageToken != nil {
		InternalSetValueByPath(parentObject, []string{"_query", "pageToken"}, fromPageToken)
	}

	if InternalGetValueByPath(fromObject, []string{"filter"}) != nil {
		return nil, fmt.Errorf("filter parameter is not supported in Gemini API")
	}

	return toObject, nil
}

func listBatchJobsConfigToVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromPageSize := InternalGetValueByPath(fromObject, []string{"pageSize"})
	if fromPageSize != nil {
		InternalSetValueByPath(parentObject, []string{"_query", "pageSize"}, fromPageSize)
	}

	fromPageToken := InternalGetValueByPath(fromObject, []string{"pageToken"})
	if fromPageToken != nil {
		InternalSetValueByPath(parentObject, []string{"_query", "pageToken"}, fromPageToken)
	}

	fromFilter := InternalGetValueByPath(fromObject, []string{"filter"})
	if fromFilter != nil {
		InternalSetValueByPath(parentObject, []string{"_query", "filter"}, fromFilter)
	}

	return toObject, nil
}

func listBatchJobsParametersToMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		_, err = listBatchJobsConfigToMldev(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}
	}

	return toObject, nil
}

func listBatchJobsParametersToVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromConfig := InternalGetValueByPath(fromObject, []string{"config"})
	if fromConfig != nil {
		_, err = listBatchJobsConfigToVertex(fromConfig.(map[string]any), toObject, rootObject)
		if err != nil {
			return nil, err
		}
	}

	return toObject, nil
}

func listBatchJobsResponseFromMldev(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromSdkHttpResponse := InternalGetValueByPath(fromObject, []string{"sdkHttpResponse"})
	if fromSdkHttpResponse != nil {
		InternalSetValueByPath(toObject, []string{"sdkHttpResponse"}, fromSdkHttpResponse)
	}

	fromNextPageToken := InternalGetValueByPath(fromObject, []string{"nextPageToken"})
	if fromNextPageToken != nil {
		InternalSetValueByPath(toObject, []string{"nextPageToken"}, fromNextPageToken)
	}

	fromBatchJobs := InternalGetValueByPath(fromObject, []string{"operations"})
	if fromBatchJobs != nil {
		fromBatchJobs, err = applyConverterToSliceWithRoot(fromBatchJobs.([]any), batchJobFromMldev, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"batchJobs"}, fromBatchJobs)
	}

	return toObject, nil
}

func listBatchJobsResponseFromVertex(fromObject map[string]any, parentObject map[string]any, rootObject map[string]any) (toObject map[string]any, err error) {
	toObject = make(map[string]any)

	fromSdkHttpResponse := InternalGetValueByPath(fromObject, []string{"sdkHttpResponse"})
	if fromSdkHttpResponse != nil {
		InternalSetValueByPath(toObject, []string{"sdkHttpResponse"}, fromSdkHttpResponse)
	}

	fromNextPageToken := InternalGetValueByPath(fromObject, []string{"nextPageToken"})
	if fromNextPageToken != nil {
		InternalSetValueByPath(toObject, []string{"nextPageToken"}, fromNextPageToken)
	}

	fromBatchJobs := InternalGetValueByPath(fromObject, []string{"batchPredictionJobs"})
	if fromBatchJobs != nil {
		fromBatchJobs, err = applyConverterToSliceWithRoot(fromBatchJobs.([]any), batchJobFromVertex, rootObject)
		if err != nil {
			return nil, err
		}

		InternalSetValueByPath(toObject, []string{"batchJobs"}, fromBatchJobs)
	}

	return toObject, nil
}

// Batches provides methods for managing the batch jobs.
// You don't need to initiate this struct. Create a client instance via NewClient, and
// then access Batches through client.Batches field.
type Batches struct {
	apiClient *InternalAPIClient
}

func (m Batches) create(ctx context.Context, model *string, src *BatchJobSource, config *CreateBatchJobConfig) (*BatchJob, error) {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"model": model, "src": src, "config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var response = new(BatchJob)
	var responseMap map[string]any
	var fromConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	var toConverter func(*InternalAPIClient, map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		toConverter = createBatchJobParametersToVertex
		fromConverter = batchJobFromVertex
	} else {
		toConverter = createBatchJobParametersToMldev
		fromConverter = batchJobFromMldev
	}

	body, err := toConverter(m.apiClient, parameterMap, nil, parameterMap)
	if err != nil {
		return nil, err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("batchPredictionJobs", urlParams)
	} else {
		path, err = InternalFormatMap("{model}:batchGenerateContent", urlParams)
	}
	if err != nil {
		return nil, fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return nil, err
		}
		path += "?" + query
		delete(body, "_query")
	}
	responseMap, err = sendRequest(ctx, m.apiClient, path, http.MethodPost, body, httpOptions)
	if err != nil {
		return nil, err
	}
	if fromConverter != nil {
		responseMap, err = fromConverter(responseMap, nil, parameterMap)
	}
	if err != nil {
		return nil, err
	}
	err = InternalMapToStruct(responseMap, response)
	if err != nil {
		return nil, err
	}

	if field, ok := reflect.TypeOf(response).Elem().FieldByName("SDKHTTPResponse"); ok {
		{
			if reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").IsValid() {
				{
					reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").Set(reflect.Zero(field.Type))
				}
			}
		}
	}

	return response, nil
}

func (m Batches) createEmbeddings(ctx context.Context, model *string, src *EmbeddingsBatchJobSource, config *CreateEmbeddingsBatchJobConfig) (*BatchJob, error) {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"model": model, "src": src, "config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var response = new(BatchJob)
	var responseMap map[string]any
	var fromConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	var toConverter func(*InternalAPIClient, map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {

		return nil, fmt.Errorf("method CreateEmbeddings is only supported in the Gemini Developer client. You can choose to use Gemini Developer client by setting ClientConfig.Backend to BackendGeminiAPI.")

	} else {
		toConverter = createEmbeddingsBatchJobParametersToMldev
		fromConverter = batchJobFromMldev
	}

	body, err := toConverter(m.apiClient, parameterMap, nil, parameterMap)
	if err != nil {
		return nil, err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("None", urlParams)
	} else {
		path, err = InternalFormatMap("{model}:asyncBatchEmbedContent", urlParams)
	}
	if err != nil {
		return nil, fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return nil, err
		}
		path += "?" + query
		delete(body, "_query")
	}
	responseMap, err = sendRequest(ctx, m.apiClient, path, http.MethodPost, body, httpOptions)
	if err != nil {
		return nil, err
	}
	if fromConverter != nil {
		responseMap, err = fromConverter(responseMap, nil, parameterMap)
	}
	if err != nil {
		return nil, err
	}
	err = InternalMapToStruct(responseMap, response)
	if err != nil {
		return nil, err
	}

	if field, ok := reflect.TypeOf(response).Elem().FieldByName("SDKHTTPResponse"); ok {
		{
			if reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").IsValid() {
				{
					reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").Set(reflect.Zero(field.Type))
				}
			}
		}
	}

	return response, nil
}

// Get gets a batch job resource.
func (m Batches) Get(ctx context.Context, name string, config *GetBatchJobConfig) (*BatchJob, error) {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"name": name, "config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var response = new(BatchJob)
	var responseMap map[string]any
	var fromConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	var toConverter func(*InternalAPIClient, map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		toConverter = getBatchJobParametersToVertex
		fromConverter = batchJobFromVertex
	} else {
		toConverter = getBatchJobParametersToMldev
		fromConverter = batchJobFromMldev
	}

	body, err := toConverter(m.apiClient, parameterMap, nil, parameterMap)
	if err != nil {
		return nil, err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("batchPredictionJobs/{name}", urlParams)
	} else {
		path, err = InternalFormatMap("batches/{name}", urlParams)
	}
	if err != nil {
		return nil, fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return nil, err
		}
		path += "?" + query
		delete(body, "_query")
	}
	responseMap, err = sendRequest(ctx, m.apiClient, path, http.MethodGet, body, httpOptions)
	if err != nil {
		return nil, err
	}
	if fromConverter != nil {
		responseMap, err = fromConverter(responseMap, nil, parameterMap)
	}
	if err != nil {
		return nil, err
	}
	err = InternalMapToStruct(responseMap, response)
	if err != nil {
		return nil, err
	}

	if field, ok := reflect.TypeOf(response).Elem().FieldByName("SDKHTTPResponse"); ok {
		{
			if reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").IsValid() {
				{
					reflect.ValueOf(response).Elem().FieldByName("SDKHTTPResponse").Set(reflect.Zero(field.Type))
				}
			}
		}
	}

	return response, nil
}

// Cancel cancels a batch job resource.
func (m Batches) Cancel(ctx context.Context, name string, config *CancelBatchJobConfig) error {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"name": name, "config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var toConverter func(*InternalAPIClient, map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		toConverter = cancelBatchJobParametersToVertex

	} else {
		toConverter = cancelBatchJobParametersToMldev

	}

	body, err := toConverter(m.apiClient, parameterMap, nil, parameterMap)
	if err != nil {
		return err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("batchPredictionJobs/{name}:cancel", urlParams)
	} else {
		path, err = InternalFormatMap("batches/{name}:cancel", urlParams)
	}
	if err != nil {
		return fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return err
		}
		path += "?" + query
		delete(body, "_query")
	}
	_, err = sendRequest(ctx, m.apiClient, path, http.MethodPost, body, httpOptions)
	if err != nil {
		return err
	}

	return nil
}

func (m Batches) list(ctx context.Context, config *ListBatchJobsConfig) (*ListBatchJobsResponse, error) {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var response = new(ListBatchJobsResponse)
	var responseMap map[string]any
	var fromConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	var toConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		toConverter = listBatchJobsParametersToVertex
		fromConverter = listBatchJobsResponseFromVertex
	} else {
		toConverter = listBatchJobsParametersToMldev
		fromConverter = listBatchJobsResponseFromMldev
	}

	body, err := toConverter(parameterMap, nil, parameterMap)
	if err != nil {
		return nil, err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("batchPredictionJobs", urlParams)
	} else {
		path, err = InternalFormatMap("batches", urlParams)
	}
	if err != nil {
		return nil, fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return nil, err
		}
		path += "?" + query
		delete(body, "_query")
	}
	responseMap, err = sendRequest(ctx, m.apiClient, path, http.MethodGet, body, httpOptions)
	if err != nil {
		return nil, err
	}
	if fromConverter != nil {
		responseMap, err = fromConverter(responseMap, nil, parameterMap)
	}
	if err != nil {
		return nil, err
	}
	err = InternalMapToStruct(responseMap, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}

// Delete deletes a batch job resource.
func (m Batches) Delete(ctx context.Context, name string, config *DeleteBatchJobConfig) (*DeleteResourceJob, error) {
	parameterMap := make(map[string]any)

	kwargs := map[string]any{"name": name, "config": config}
	InternalDeepMarshal(kwargs, &parameterMap)

	var httpOptions *HTTPOptions
	if config == nil || config.HTTPOptions == nil {
		httpOptions = &HTTPOptions{}
	} else {
		httpOptions = config.HTTPOptions
	}
	if httpOptions.Headers == nil {
		httpOptions.Headers = http.Header{}
	}
	var response = new(DeleteResourceJob)
	var responseMap map[string]any
	var fromConverter func(map[string]any, map[string]any, map[string]any) (map[string]any, error)
	var toConverter func(*InternalAPIClient, map[string]any, map[string]any, map[string]any) (map[string]any, error)
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		toConverter = deleteBatchJobParametersToVertex
		fromConverter = deleteResourceJobFromVertex
	} else {
		toConverter = deleteBatchJobParametersToMldev
		fromConverter = deleteResourceJobFromMldev
	}

	body, err := toConverter(m.apiClient, parameterMap, nil, parameterMap)
	if err != nil {
		return nil, err
	}

	var path string
	var urlParams map[string]any
	if _, ok := body["_url"]; ok {
		urlParams = body["_url"].(map[string]any)
		delete(body, "_url")
	}
	if m.apiClient.ClientConfig().Backend == BackendVertexAI {
		path, err = InternalFormatMap("batchPredictionJobs/{name}", urlParams)
	} else {
		path, err = InternalFormatMap("batches/{name}", urlParams)
	}
	if err != nil {
		return nil, fmt.Errorf("invalid url params: %#v.\n%w", urlParams, err)
	}
	if _, ok := body["_query"]; ok {
		query, err := InternalCreateURLQuery(body["_query"].(map[string]any))
		if err != nil {
			return nil, err
		}
		path += "?" + query
		delete(body, "_query")
	}
	responseMap, err = sendRequest(ctx, m.apiClient, path, http.MethodDelete, body, httpOptions)
	if err != nil {
		return nil, err
	}
	if fromConverter != nil {
		responseMap, err = fromConverter(responseMap, nil, parameterMap)
	}
	if err != nil {
		return nil, err
	}
	err = InternalMapToStruct(responseMap, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}

// List retrieves a paginated list of batch_jobs resources.
func (m Batches) List(ctx context.Context, config *ListBatchJobsConfig) (Page[BatchJob], error) {
	listFunc := func(ctx context.Context, config map[string]any) ([]*BatchJob, string, *HTTPResponse, error) {
		var c ListBatchJobsConfig
		if err := InternalMapToStruct(config, &c); err != nil {
			return nil, "", nil, err
		}
		resp, err := m.list(ctx, &c)
		if err != nil {
			return nil, "", nil, err
		}
		return resp.BatchJobs, resp.NextPageToken, resp.SDKHTTPResponse, nil
	}
	c := make(map[string]any)
	InternalDeepMarshal(config, &c)
	return newPage(ctx, "batchJobs", c, listFunc)
}

// All retrieves all batch_jobs resources.
//
// This method handles pagination internally, making multiple API calls as needed
// to fetch all entries. It returns an iterator that yields each "batchJobs"
// entry one by one. You do not need to manage pagination
// tokens or make multiple calls to retrieve all data.
func (m Batches) All(ctx context.Context) iter.Seq2[*BatchJob, error] {
	listFunc := func(ctx context.Context, config map[string]any) ([]*BatchJob, string, *HTTPResponse, error) {
		var c ListBatchJobsConfig
		if err := InternalMapToStruct(config, &c); err != nil {
			return nil, "", nil, err
		}
		resp, err := m.list(ctx, &c)
		if err != nil {
			return nil, "", nil, err
		}
		return resp.BatchJobs, resp.NextPageToken, resp.SDKHTTPResponse, nil
	}
	p, err := newPage(ctx, "batchJobs", map[string]any{}, listFunc)
	if err != nil {
		return yieldErrorAndEndIterator[BatchJob](err)
	}
	return p.all(ctx)
}

// Create a batch job.
func (b Batches) Create(ctx context.Context, model string, src *BatchJobSource, config *CreateBatchJobConfig) (*BatchJob, error) {
	if b.apiClient.clientConfig.Backend == BackendVertexAI {
		if len(src.InlinedRequests) > 0 {
			return nil, fmt.Errorf("inlinedRequests parameter is not supported in Vertex AI")
		}
		if src.FileName != "" {
			return nil, fmt.Errorf("fileName parameter is not supported in Vertex AI")
		}
		if len(src.GCSURI) != 0 && src.BigqueryURI != "" {
			return nil, fmt.Errorf("Only one of GCSURI ([]string) and BigqueryURI (string) can be set.")
		}
		if len(src.GCSURI) == 0 && src.BigqueryURI == "" {
			return nil, fmt.Errorf("One of GCSURI ([]string) and BigqueryURI (string) must be set.")
		}
	} else {
		if src.FileName != "" && len(src.InlinedRequests) > 0 {
			return nil, fmt.Errorf("Only one of FileName and InlinedRequests can be set.")
		}
		if src.FileName == "" && len(src.InlinedRequests) == 0 {
			return nil, fmt.Errorf("one of FileName and InlinedRequests must be set.")
		}
	}
	return b.create(ctx, &model, src, config)
}

var experimentalWarningBatchesCreateEmbeddings sync.Once

// Create an embeddings batch job.
func (b Batches) CreateEmbeddings(ctx context.Context, model *string, src *EmbeddingsBatchJobSource, config *CreateEmbeddingsBatchJobConfig) (*BatchJob, error) {
	experimentalWarningBatchesCreateEmbeddings.Do(func() {
		log.Println("The SDK's CreateEmbeddings implementation is experimental, and may change in future versions.")
	})
	if b.apiClient.clientConfig.Backend == BackendVertexAI {
		return nil, fmt.Errorf("Vertex AI does not support batches.createEmbeddings.")
	}
	return b.createEmbeddings(ctx, model, src, config)
}
