/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package client

import (
	"bytes"
	"context"
	"io"
	"net/http"
	"net/url"
	"strings"
)

// ModelEndpointsAPIService ModelEndpointsAPI service
type ModelEndpointsAPIService service

type ApiModelsModelIdEndpointsGetRequest struct {
	ctx        context.Context
	ApiService *ModelEndpointsAPIService
	modelId    int32
}

func (r ApiModelsModelIdEndpointsGetRequest) Execute() ([]ModelEndpoint, *http.Response, error) {
	return r.ApiService.ModelsModelIdEndpointsGetExecute(r)
}

/*
ModelsModelIdEndpointsGet List model endpoint

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param modelId
	@return ApiModelsModelIdEndpointsGetRequest
*/
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsGet(ctx context.Context, modelId int32) ApiModelsModelIdEndpointsGetRequest {
	return ApiModelsModelIdEndpointsGetRequest{
		ApiService: a,
		ctx:        ctx,
		modelId:    modelId,
	}
}

// Execute executes the request
//
//	@return []ModelEndpoint
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsGetExecute(r ApiModelsModelIdEndpointsGetRequest) ([]ModelEndpoint, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue []ModelEndpoint
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ModelsModelIdEndpointsGet")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/models/{model_id}/endpoints"
	localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest struct {
	ctx             context.Context
	ApiService      *ModelEndpointsAPIService
	modelId         int32
	modelEndpointId int32
}

func (r ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest) Execute() (*http.Response, error) {
	return r.ApiService.ModelsModelIdEndpointsModelEndpointIdDeleteExecute(r)
}

/*
ModelsModelIdEndpointsModelEndpointIdDelete Stop serving traffic to the model endpoint, then delete it.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param modelId
	@param modelEndpointId
	@return ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest
*/
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdDelete(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest {
	return ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest{
		ApiService:      a,
		ctx:             ctx,
		modelId:         modelId,
		modelEndpointId: modelEndpointId,
	}
}

// Execute executes the request
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdDeleteExecute(r ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod = http.MethodDelete
		localVarPostBody   interface{}
		formFiles          []formFile
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ModelsModelIdEndpointsModelEndpointIdDelete")
	if err != nil {
		return nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/models/{model_id}/endpoints/{model_endpoint_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"model_endpoint_id"+"}", url.PathEscape(parameterValueToString(r.modelEndpointId, "modelEndpointId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}

type ApiModelsModelIdEndpointsModelEndpointIdGetRequest struct {
	ctx             context.Context
	ApiService      *ModelEndpointsAPIService
	modelId         int32
	modelEndpointId int32
}

func (r ApiModelsModelIdEndpointsModelEndpointIdGetRequest) Execute() (*ModelEndpoint, *http.Response, error) {
	return r.ApiService.ModelsModelIdEndpointsModelEndpointIdGetExecute(r)
}

/*
ModelsModelIdEndpointsModelEndpointIdGet Get a model endpoint

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param modelId
	@param modelEndpointId
	@return ApiModelsModelIdEndpointsModelEndpointIdGetRequest
*/
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdGet(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdGetRequest {
	return ApiModelsModelIdEndpointsModelEndpointIdGetRequest{
		ApiService:      a,
		ctx:             ctx,
		modelId:         modelId,
		modelEndpointId: modelEndpointId,
	}
}

// Execute executes the request
//
//	@return ModelEndpoint
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdGetExecute(r ApiModelsModelIdEndpointsModelEndpointIdGetRequest) (*ModelEndpoint, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *ModelEndpoint
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ModelsModelIdEndpointsModelEndpointIdGet")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/models/{model_id}/endpoints/{model_endpoint_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"model_endpoint_id"+"}", url.PathEscape(parameterValueToString(r.modelEndpointId, "modelEndpointId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiModelsModelIdEndpointsModelEndpointIdPutRequest struct {
	ctx             context.Context
	ApiService      *ModelEndpointsAPIService
	modelId         int32
	modelEndpointId int32
	body            *ModelEndpoint
}

func (r ApiModelsModelIdEndpointsModelEndpointIdPutRequest) Body(body ModelEndpoint) ApiModelsModelIdEndpointsModelEndpointIdPutRequest {
	r.body = &body
	return r
}

func (r ApiModelsModelIdEndpointsModelEndpointIdPutRequest) Execute() (*ModelEndpoint, *http.Response, error) {
	return r.ApiService.ModelsModelIdEndpointsModelEndpointIdPutExecute(r)
}

/*
ModelsModelIdEndpointsModelEndpointIdPut Update model endpoint data. Mainly used to update its rule.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param modelId
	@param modelEndpointId
	@return ApiModelsModelIdEndpointsModelEndpointIdPutRequest
*/
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdPut(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdPutRequest {
	return ApiModelsModelIdEndpointsModelEndpointIdPutRequest{
		ApiService:      a,
		ctx:             ctx,
		modelId:         modelId,
		modelEndpointId: modelEndpointId,
	}
}

// Execute executes the request
//
//	@return ModelEndpoint
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdPutExecute(r ApiModelsModelIdEndpointsModelEndpointIdPutRequest) (*ModelEndpoint, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodPut
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *ModelEndpoint
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ModelsModelIdEndpointsModelEndpointIdPut")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/models/{model_id}/endpoints/{model_endpoint_id}"
	localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"model_endpoint_id"+"}", url.PathEscape(parameterValueToString(r.modelEndpointId, "modelEndpointId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.body
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiModelsModelIdEndpointsPostRequest struct {
	ctx        context.Context
	ApiService *ModelEndpointsAPIService
	modelId    int32
	body       *ModelEndpoint
}

// Model endpoint object that has to be added
func (r ApiModelsModelIdEndpointsPostRequest) Body(body ModelEndpoint) ApiModelsModelIdEndpointsPostRequest {
	r.body = &body
	return r
}

func (r ApiModelsModelIdEndpointsPostRequest) Execute() (*ModelEndpoint, *http.Response, error) {
	return r.ApiService.ModelsModelIdEndpointsPostExecute(r)
}

/*
ModelsModelIdEndpointsPost Create a model endpoint

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param modelId
	@return ApiModelsModelIdEndpointsPostRequest
*/
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsPost(ctx context.Context, modelId int32) ApiModelsModelIdEndpointsPostRequest {
	return ApiModelsModelIdEndpointsPostRequest{
		ApiService: a,
		ctx:        ctx,
		modelId:    modelId,
	}
}

// Execute executes the request
//
//	@return ModelEndpoint
func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsPostExecute(r ApiModelsModelIdEndpointsPostRequest) (*ModelEndpoint, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodPost
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *ModelEndpoint
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ModelsModelIdEndpointsPost")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/models/{model_id}/endpoints"
	localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}
	if r.body == nil {
		return localVarReturnValue, nil, reportError("body is required and must be specified")
	}

	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.body
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}

type ApiProjectsProjectIdModelEndpointsGetRequest struct {
	ctx        context.Context
	ApiService *ModelEndpointsAPIService
	projectId  int32
	region     *string
}

// Filter list of model endpoints by specific environment&#39;s &#x60;region&#x60;
func (r ApiProjectsProjectIdModelEndpointsGetRequest) Region(region string) ApiProjectsProjectIdModelEndpointsGetRequest {
	r.region = &region
	return r
}

func (r ApiProjectsProjectIdModelEndpointsGetRequest) Execute() ([]ModelEndpoint, *http.Response, error) {
	return r.ApiService.ProjectsProjectIdModelEndpointsGetExecute(r)
}

/*
ProjectsProjectIdModelEndpointsGet List existing model endpoints for all models in particular project

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param projectId Filter list of model endpoints by specific `project_id`
	@return ApiProjectsProjectIdModelEndpointsGetRequest
*/
func (a *ModelEndpointsAPIService) ProjectsProjectIdModelEndpointsGet(ctx context.Context, projectId int32) ApiProjectsProjectIdModelEndpointsGetRequest {
	return ApiProjectsProjectIdModelEndpointsGetRequest{
		ApiService: a,
		ctx:        ctx,
		projectId:  projectId,
	}
}

// Execute executes the request
//
//	@return []ModelEndpoint
func (a *ModelEndpointsAPIService) ProjectsProjectIdModelEndpointsGetExecute(r ApiProjectsProjectIdModelEndpointsGetRequest) ([]ModelEndpoint, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue []ModelEndpoint
	)

	localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ModelEndpointsAPIService.ProjectsProjectIdModelEndpointsGet")
	if err != nil {
		return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
	}

	localVarPath := localBasePath + "/projects/{project_id}/model_endpoints"
	localVarPath = strings.Replace(localVarPath, "{"+"project_id"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1)

	localVarHeaderParams := make(map[string]string)
	localVarQueryParams := url.Values{}
	localVarFormParams := url.Values{}

	if r.region != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "region", r.region, "")
	}
	// to determine the Content-Type header
	localVarHTTPContentTypes := []string{}

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
	localVarHTTPHeaderAccepts := []string{"*/*"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.ctx != nil {
		// API Key Authentication
		if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
			if apiKey, ok := auth["Bearer"]; ok {
				var key string
				if apiKey.Prefix != "" {
					key = apiKey.Prefix + " " + apiKey.Key
				} else {
					key = apiKey.Key
				}
				localVarHeaderParams["Authorization"] = key
			}
		}
	}
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return localVarReturnValue, nil, err
	}

	localVarHTTPResponse, err := a.client.callAPI(req)
	if err != nil || localVarHTTPResponse == nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body.Close()
	localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
	if err != nil {
		return localVarReturnValue, localVarHTTPResponse, err
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
	if err != nil {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: err.Error(),
		}
		return localVarReturnValue, localVarHTTPResponse, newErr
	}

	return localVarReturnValue, localVarHTTPResponse, nil
}
