/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

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


type DockerRegistryAPI interface {

	/*
	CreateRegistry Create registry

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@return DockerRegistryAPICreateRegistryRequest
	*/
	CreateRegistry(ctx context.Context) DockerRegistryAPICreateRegistryRequest

	// CreateRegistryExecute executes the request
	//  @return DockerRegistry
	CreateRegistryExecute(r DockerRegistryAPICreateRegistryRequest) (*DockerRegistry, *http.Response, error)

	/*
	DeleteRegistry Delete registry

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param id ID of the docker registry
	@return DockerRegistryAPIDeleteRegistryRequest
	*/
	DeleteRegistry(ctx context.Context, id string) DockerRegistryAPIDeleteRegistryRequest

	// DeleteRegistryExecute executes the request
	DeleteRegistryExecute(r DockerRegistryAPIDeleteRegistryRequest) (*http.Response, error)

	/*
	GetRegistry Get registry

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param id ID of the docker registry
	@return DockerRegistryAPIGetRegistryRequest
	*/
	GetRegistry(ctx context.Context, id string) DockerRegistryAPIGetRegistryRequest

	// GetRegistryExecute executes the request
	//  @return DockerRegistry
	GetRegistryExecute(r DockerRegistryAPIGetRegistryRequest) (*DockerRegistry, *http.Response, error)

	/*
	GetTransientPushAccess Get temporary registry access for pushing snapshots

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@return DockerRegistryAPIGetTransientPushAccessRequest
	*/
	GetTransientPushAccess(ctx context.Context) DockerRegistryAPIGetTransientPushAccessRequest

	// GetTransientPushAccessExecute executes the request
	//  @return RegistryPushAccessDto
	GetTransientPushAccessExecute(r DockerRegistryAPIGetTransientPushAccessRequest) (*RegistryPushAccessDto, *http.Response, error)

	/*
	ListRegistries List registries

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@return DockerRegistryAPIListRegistriesRequest
	*/
	ListRegistries(ctx context.Context) DockerRegistryAPIListRegistriesRequest

	// ListRegistriesExecute executes the request
	//  @return []DockerRegistry
	ListRegistriesExecute(r DockerRegistryAPIListRegistriesRequest) ([]DockerRegistry, *http.Response, error)

	/*
	UpdateRegistry Update registry

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param id ID of the docker registry
	@return DockerRegistryAPIUpdateRegistryRequest
	*/
	UpdateRegistry(ctx context.Context, id string) DockerRegistryAPIUpdateRegistryRequest

	// UpdateRegistryExecute executes the request
	//  @return DockerRegistry
	UpdateRegistryExecute(r DockerRegistryAPIUpdateRegistryRequest) (*DockerRegistry, *http.Response, error)
}

// DockerRegistryAPIService DockerRegistryAPI service
type DockerRegistryAPIService service

type DockerRegistryAPICreateRegistryRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	createDockerRegistry *CreateDockerRegistry
	xDaytonaOrganizationID *string
}

func (r DockerRegistryAPICreateRegistryRequest) CreateDockerRegistry(createDockerRegistry CreateDockerRegistry) DockerRegistryAPICreateRegistryRequest {
	r.createDockerRegistry = &createDockerRegistry
	return r
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPICreateRegistryRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPICreateRegistryRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

func (r DockerRegistryAPICreateRegistryRequest) Execute() (*DockerRegistry, *http.Response, error) {
	return r.ApiService.CreateRegistryExecute(r)
}

/*
CreateRegistry Create registry

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

// Execute executes the request
//  @return DockerRegistry
func (a *DockerRegistryAPIService) CreateRegistryExecute(r DockerRegistryAPICreateRegistryRequest) (*DockerRegistry, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPost
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *DockerRegistry
	)

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

	localVarPath := localBasePath + "/docker-registry"

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	// body params
	localVarPostBody = r.createDockerRegistry
	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 DockerRegistryAPIDeleteRegistryRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	id string
	xDaytonaOrganizationID *string
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPIDeleteRegistryRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPIDeleteRegistryRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

func (r DockerRegistryAPIDeleteRegistryRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeleteRegistryExecute(r)
}

/*
DeleteRegistry Delete registry

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param id ID of the docker registry
 @return DockerRegistryAPIDeleteRegistryRequest
*/
func (a *DockerRegistryAPIService) DeleteRegistry(ctx context.Context, id string) DockerRegistryAPIDeleteRegistryRequest {
	return DockerRegistryAPIDeleteRegistryRequest{
		ApiService: a,
		ctx: ctx,
		id: id,
	}
}

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

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

	localVarPath := localBasePath + "/docker-registry/{id}"
	localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	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 DockerRegistryAPIGetRegistryRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	id string
	xDaytonaOrganizationID *string
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPIGetRegistryRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPIGetRegistryRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

func (r DockerRegistryAPIGetRegistryRequest) Execute() (*DockerRegistry, *http.Response, error) {
	return r.ApiService.GetRegistryExecute(r)
}

/*
GetRegistry Get registry

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param id ID of the docker registry
 @return DockerRegistryAPIGetRegistryRequest
*/
func (a *DockerRegistryAPIService) GetRegistry(ctx context.Context, id string) DockerRegistryAPIGetRegistryRequest {
	return DockerRegistryAPIGetRegistryRequest{
		ApiService: a,
		ctx: ctx,
		id: id,
	}
}

// Execute executes the request
//  @return DockerRegistry
func (a *DockerRegistryAPIService) GetRegistryExecute(r DockerRegistryAPIGetRegistryRequest) (*DockerRegistry, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *DockerRegistry
	)

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

	localVarPath := localBasePath + "/docker-registry/{id}"
	localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	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 DockerRegistryAPIGetTransientPushAccessRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	xDaytonaOrganizationID *string
	regionId *string
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPIGetTransientPushAccessRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPIGetTransientPushAccessRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

// ID of the region where the snapshot will be available (defaults to organization default region)
func (r DockerRegistryAPIGetTransientPushAccessRequest) RegionId(regionId string) DockerRegistryAPIGetTransientPushAccessRequest {
	r.regionId = &regionId
	return r
}

func (r DockerRegistryAPIGetTransientPushAccessRequest) Execute() (*RegistryPushAccessDto, *http.Response, error) {
	return r.ApiService.GetTransientPushAccessExecute(r)
}

/*
GetTransientPushAccess Get temporary registry access for pushing snapshots

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

// Execute executes the request
//  @return RegistryPushAccessDto
func (a *DockerRegistryAPIService) GetTransientPushAccessExecute(r DockerRegistryAPIGetTransientPushAccessRequest) (*RegistryPushAccessDto, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *RegistryPushAccessDto
	)

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

	localVarPath := localBasePath + "/docker-registry/registry-push-access"

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

	if r.regionId != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "regionId", r.regionId, "form", "")
	}
	// 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{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	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 DockerRegistryAPIListRegistriesRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	xDaytonaOrganizationID *string
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPIListRegistriesRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPIListRegistriesRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

func (r DockerRegistryAPIListRegistriesRequest) Execute() ([]DockerRegistry, *http.Response, error) {
	return r.ApiService.ListRegistriesExecute(r)
}

/*
ListRegistries List registries

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

// Execute executes the request
//  @return []DockerRegistry
func (a *DockerRegistryAPIService) ListRegistriesExecute(r DockerRegistryAPIListRegistriesRequest) ([]DockerRegistry, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []DockerRegistry
	)

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

	localVarPath := localBasePath + "/docker-registry"

	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{"application/json"}

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	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 DockerRegistryAPIUpdateRegistryRequest struct {
	ctx context.Context
	ApiService DockerRegistryAPI
	id string
	updateDockerRegistry *UpdateDockerRegistry
	xDaytonaOrganizationID *string
}

func (r DockerRegistryAPIUpdateRegistryRequest) UpdateDockerRegistry(updateDockerRegistry UpdateDockerRegistry) DockerRegistryAPIUpdateRegistryRequest {
	r.updateDockerRegistry = &updateDockerRegistry
	return r
}

// Use with JWT to specify the organization ID
func (r DockerRegistryAPIUpdateRegistryRequest) XDaytonaOrganizationID(xDaytonaOrganizationID string) DockerRegistryAPIUpdateRegistryRequest {
	r.xDaytonaOrganizationID = &xDaytonaOrganizationID
	return r
}

func (r DockerRegistryAPIUpdateRegistryRequest) Execute() (*DockerRegistry, *http.Response, error) {
	return r.ApiService.UpdateRegistryExecute(r)
}

/*
UpdateRegistry Update registry

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param id ID of the docker registry
 @return DockerRegistryAPIUpdateRegistryRequest
*/
func (a *DockerRegistryAPIService) UpdateRegistry(ctx context.Context, id string) DockerRegistryAPIUpdateRegistryRequest {
	return DockerRegistryAPIUpdateRegistryRequest{
		ApiService: a,
		ctx: ctx,
		id: id,
	}
}

// Execute executes the request
//  @return DockerRegistry
func (a *DockerRegistryAPIService) UpdateRegistryExecute(r DockerRegistryAPIUpdateRegistryRequest) (*DockerRegistry, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPatch
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *DockerRegistry
	)

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

	localVarPath := localBasePath + "/docker-registry/{id}"
	localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	if r.xDaytonaOrganizationID != nil {
		parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Daytona-Organization-ID", r.xDaytonaOrganizationID, "simple", "")
	}
	// body params
	localVarPostBody = r.updateDockerRegistry
	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
}
