/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

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


type DeploymentsV2ManagementAPIAPI interface {

	/*
	AssignReleaseTags Update and replace the tags of a release. 

	Assigns tags to a release. The tags associated with the release will be
replaced with the ones defined in the request body.

LIMITATIONS:
  * Max 20 tags can be assigned to a single release.
  * There can be no more than 100 unique tag keys in total.


	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param releaseName Name of the release
	@return ApiAssignReleaseTagsRequest
	*/
	AssignReleaseTags(ctx context.Context, releaseName string) ApiAssignReleaseTagsRequest

	// AssignReleaseTagsExecute executes the request
	AssignReleaseTagsExecute(r ApiAssignReleaseTagsRequest) (*http.Response, error)

	/*
	DeleteReleases Delete the releases with given names

	Deletes releases with names provided in the message body.
Releases used by deployments in progress can not be deleted
until deployment finishes.


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

	// DeleteReleasesExecute executes the request
	DeleteReleasesExecute(r ApiDeleteReleasesRequest) (*http.Response, error)

	/*
	DeploymentsV2ListArtifactsWithPagination Lists known artifacts. 

	Returns a collection of all artifacts sorted by name.


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

	// DeploymentsV2ListArtifactsWithPaginationExecute executes the request
	//  @return []ArtifactV2
	DeploymentsV2ListArtifactsWithPaginationExecute(r ApiDeploymentsV2ListArtifactsWithPaginationRequest) ([]ArtifactV2, *http.Response, error)

	/*
	DeploymentsV2ListDeployments List all the deployments matching the specified filter parameters

	Returns a filtered collection of deployments in the system. While you can provide multiple
deployment identifiers, and multiple names to get the multiple deployments you cannot mix
the ids and names in a one query expecting to get deployments that match both names or ids.
The endpoint will return the deployments that match the ids and the name, if combined.


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

	// DeploymentsV2ListDeploymentsExecute executes the request
	//  @return []DeploymentV2
	DeploymentsV2ListDeploymentsExecute(r ApiDeploymentsV2ListDeploymentsRequest) ([]DeploymentV2, *http.Response, error)

	/*
	DeploymentsV2ListReleasesWithPagination List releases 

	Returns a collection of releases, allows filtering by release name and sorting
by name or last modification date.


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

	// DeploymentsV2ListReleasesWithPaginationExecute executes the request
	//  @return []ReleaseV2
	DeploymentsV2ListReleasesWithPaginationExecute(r ApiDeploymentsV2ListReleasesWithPaginationRequest) ([]ReleaseV2, *http.Response, error)

	/*
	GetReleaseWithGivenName Get release 

	Returns the release with given name.


	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param releaseName Name of the release
	@return ApiGetReleaseWithGivenNameRequest
	*/
	GetReleaseWithGivenName(ctx context.Context, releaseName string) ApiGetReleaseWithGivenNameRequest

	// GetReleaseWithGivenNameExecute executes the request
	//  @return ReleaseV2
	GetReleaseWithGivenNameExecute(r ApiGetReleaseWithGivenNameRequest) (*ReleaseV2, *http.Response, error)

	/*
	ListReleaseTags Lists all available tags for releases. 

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

	// ListReleaseTagsExecute executes the request
	//  @return []string
	ListReleaseTagsExecute(r ApiListReleaseTagsRequest) ([]string, *http.Response, error)

	/*
	ListReleaseTypes Lists all release update types. 

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

	// ListReleaseTypesExecute executes the request
	//  @return []string
	ListReleaseTypesExecute(r ApiListReleaseTypesRequest) ([]string, *http.Response, error)

	/*
	UpdateReleaseInformation Update selected fields of the Release object. 

	Updates the Release object.


	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param releaseName Name of the release
	@return ApiUpdateReleaseInformationRequest
	*/
	UpdateReleaseInformation(ctx context.Context, releaseName string) ApiUpdateReleaseInformationRequest

	// UpdateReleaseInformationExecute executes the request
	UpdateReleaseInformationExecute(r ApiUpdateReleaseInformationRequest) (*http.Response, error)
}

// DeploymentsV2ManagementAPIAPIService DeploymentsV2ManagementAPIAPI service
type DeploymentsV2ManagementAPIAPIService service

type ApiAssignReleaseTagsRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	releaseName string
	requestBody *[]string
}

func (r ApiAssignReleaseTagsRequest) RequestBody(requestBody []string) ApiAssignReleaseTagsRequest {
	r.requestBody = &requestBody
	return r
}

func (r ApiAssignReleaseTagsRequest) Execute() (*http.Response, error) {
	return r.ApiService.AssignReleaseTagsExecute(r)
}

/*
AssignReleaseTags Update and replace the tags of a release. 

Assigns tags to a release. The tags associated with the release will be
replaced with the ones defined in the request body.

LIMITATIONS:
  * Max 20 tags can be assigned to a single release.
  * There can be no more than 100 unique tag keys in total.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param releaseName Name of the release
 @return ApiAssignReleaseTagsRequest
*/
func (a *DeploymentsV2ManagementAPIAPIService) AssignReleaseTags(ctx context.Context, releaseName string) ApiAssignReleaseTagsRequest {
	return ApiAssignReleaseTagsRequest{
		ApiService: a,
		ctx: ctx,
		releaseName: releaseName,
	}
}

// Execute executes the request
func (a *DeploymentsV2ManagementAPIAPIService) AssignReleaseTagsExecute(r ApiAssignReleaseTagsRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPut
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments/releases/{release_name}/tags"
	localVarPath = strings.Replace(localVarPath, "{"+"release_name"+"}", url.PathEscape(parameterValueToString(r.releaseName, "releaseName")), -1)

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

	// 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
	}
	// body params
	localVarPostBody = r.requestBody
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 409 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}

type ApiDeleteReleasesRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	name *string
}

// Name of the release to be deleted
func (r ApiDeleteReleasesRequest) Name(name string) ApiDeleteReleasesRequest {
	r.name = &name
	return r
}

func (r ApiDeleteReleasesRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeleteReleasesExecute(r)
}

/*
DeleteReleases Delete the releases with given names

Deletes releases with names provided in the message body.
Releases used by deployments in progress can not be deleted
until deployment finishes.


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

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

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments/releases"

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

	parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 409 {
			var v ReleasesDeleteError
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}

type ApiDeploymentsV2ListArtifactsWithPaginationRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	name *[]string
	description *string
	deviceType *string
	page *int32
	perPage *int32
}

// Artifact(s) name(s) filter. Multiple names can be provided (e.g., &#x60;?name&#x3D;foo&amp;name&#x3D;bar&#x60;). Supports exact matching or prefix matching by adding &#x60;*&#x60; to the end (e.g., &#x60;foo*&#x60;). Note: when using prefix matching you may pass only a single value and you cannot combine prefix matching and exact matching in the same request. 
func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) Name(name []string) ApiDeploymentsV2ListArtifactsWithPaginationRequest {
	r.name = &name
	return r
}

// Artifact description filter. Supports exact matching or prefix matching by adding &#x60;*&#x60; to the end (e.g., &#x60;foo*&#x60;). 
func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) Description(description string) ApiDeploymentsV2ListArtifactsWithPaginationRequest {
	r.description = &description
	return r
}

// Artifact device type filter. Supports exact matching or prefix matching by adding &#x60;*&#x60; to the end (e.g., &#x60;foo*&#x60;). 
func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) DeviceType(deviceType string) ApiDeploymentsV2ListArtifactsWithPaginationRequest {
	r.deviceType = &deviceType
	return r
}

// Starting page.
func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) Page(page int32) ApiDeploymentsV2ListArtifactsWithPaginationRequest {
	r.page = &page
	return r
}

// Maximum number of results per page.
func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) PerPage(perPage int32) ApiDeploymentsV2ListArtifactsWithPaginationRequest {
	r.perPage = &perPage
	return r
}

func (r ApiDeploymentsV2ListArtifactsWithPaginationRequest) Execute() ([]ArtifactV2, *http.Response, error) {
	return r.ApiService.DeploymentsV2ListArtifactsWithPaginationExecute(r)
}

/*
DeploymentsV2ListArtifactsWithPagination Lists known artifacts. 

Returns a collection of all artifacts sorted by name.


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

// Execute executes the request
//  @return []ArtifactV2
func (a *DeploymentsV2ManagementAPIAPIService) DeploymentsV2ListArtifactsWithPaginationExecute(r ApiDeploymentsV2ListArtifactsWithPaginationRequest) ([]ArtifactV2, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []ArtifactV2
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/artifacts"

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

	if r.name != nil {
		t := *r.name
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "name", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "name", t, "form", "multi")
		}
	}
	if r.description != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "description", r.description, "form", "")
	}
	if r.deviceType != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "device_type", r.deviceType, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	} else {
		var defaultValue int32 = 1
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", defaultValue, "form", "")
		r.page = &defaultValue
	}
	if r.perPage != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", r.perPage, "form", "")
	} else {
		var defaultValue int32 = 20
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", defaultValue, "form", "")
		r.perPage = &defaultValue
	}
	// 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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiDeploymentsV2ListDeploymentsRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	id *string
	name *string
	status *string
	type_ *string
	page *int32
	perPage *int32
	createdBefore *int32
	createdAfter *int32
	sort *string
	idAttribute *string
	idScope *string
}

// Deployment identifier. You can provide it multiple times to query a set of deployments. 
func (r ApiDeploymentsV2ListDeploymentsRequest) Id(id string) ApiDeploymentsV2ListDeploymentsRequest {
	r.id = &id
	return r
}

// Deployment name. You can provide it multiple times to query a set of deployments. 
func (r ApiDeploymentsV2ListDeploymentsRequest) Name(name string) ApiDeploymentsV2ListDeploymentsRequest {
	r.name = &name
	return r
}

// Deployment status filter.
func (r ApiDeploymentsV2ListDeploymentsRequest) Status(status string) ApiDeploymentsV2ListDeploymentsRequest {
	r.status = &status
	return r
}

// Deployment type filter. 
func (r ApiDeploymentsV2ListDeploymentsRequest) Type_(type_ string) ApiDeploymentsV2ListDeploymentsRequest {
	r.type_ = &type_
	return r
}

// Results page number
func (r ApiDeploymentsV2ListDeploymentsRequest) Page(page int32) ApiDeploymentsV2ListDeploymentsRequest {
	r.page = &page
	return r
}

// Maximum number of results per page.
func (r ApiDeploymentsV2ListDeploymentsRequest) PerPage(perPage int32) ApiDeploymentsV2ListDeploymentsRequest {
	r.perPage = &perPage
	return r
}

// List only deployments created before and equal to Unix timestamp (UTC)
func (r ApiDeploymentsV2ListDeploymentsRequest) CreatedBefore(createdBefore int32) ApiDeploymentsV2ListDeploymentsRequest {
	r.createdBefore = &createdBefore
	return r
}

// List only deployments created after and equal to Unix timestamp (UTC)
func (r ApiDeploymentsV2ListDeploymentsRequest) CreatedAfter(createdAfter int32) ApiDeploymentsV2ListDeploymentsRequest {
	r.createdAfter = &createdAfter
	return r
}

// Supports sorting the deployments list by creation date. 
func (r ApiDeploymentsV2ListDeploymentsRequest) Sort(sort string) ApiDeploymentsV2ListDeploymentsRequest {
	r.sort = &sort
	return r
}

// Device identity or inventory attribute name to use for a fallback device lookup when no deployments match the given name filter. When set, the server resolves the first name value against the device inventory/identity and returns deployments targeting the matched device. 
func (r ApiDeploymentsV2ListDeploymentsRequest) IdAttribute(idAttribute string) ApiDeploymentsV2ListDeploymentsRequest {
	r.idAttribute = &idAttribute
	return r
}

// Scope for the id_attribute parameter. Defaults to \&quot;identity\&quot;, unless id_attribute is \&quot;name\&quot; in which case it defaults to \&quot;inventory\&quot;. 
func (r ApiDeploymentsV2ListDeploymentsRequest) IdScope(idScope string) ApiDeploymentsV2ListDeploymentsRequest {
	r.idScope = &idScope
	return r
}

func (r ApiDeploymentsV2ListDeploymentsRequest) Execute() ([]DeploymentV2, *http.Response, error) {
	return r.ApiService.DeploymentsV2ListDeploymentsExecute(r)
}

/*
DeploymentsV2ListDeployments List all the deployments matching the specified filter parameters

Returns a filtered collection of deployments in the system. While you can provide multiple
deployment identifiers, and multiple names to get the multiple deployments you cannot mix
the ids and names in a one query expecting to get deployments that match both names or ids.
The endpoint will return the deployments that match the ids and the name, if combined.


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

// Execute executes the request
//  @return []DeploymentV2
func (a *DeploymentsV2ManagementAPIAPIService) DeploymentsV2ListDeploymentsExecute(r ApiDeploymentsV2ListDeploymentsRequest) ([]DeploymentV2, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []DeploymentV2
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments"

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

	if r.id != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "id", r.id, "form", "")
	}
	if r.name != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "")
	}
	if r.status != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
	}
	if r.type_ != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "type", r.type_, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	} else {
		var defaultValue int32 = 1
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", defaultValue, "form", "")
		r.page = &defaultValue
	}
	if r.perPage != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", r.perPage, "form", "")
	} else {
		var defaultValue int32 = 20
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", defaultValue, "form", "")
		r.perPage = &defaultValue
	}
	if r.createdBefore != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "created_before", r.createdBefore, "form", "")
	}
	if r.createdAfter != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "created_after", r.createdAfter, "form", "")
	}
	if r.sort != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "form", "")
	}
	if r.idAttribute != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "id_attribute", r.idAttribute, "form", "")
	}
	if r.idScope != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "id_scope", r.idScope, "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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiDeploymentsV2ListReleasesWithPaginationRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	name *string
	tag *[]string
	updateType *string
	page *int32
	perPage *int32
	sort *string
}

// Release name filter.
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) Name(name string) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.name = &name
	return r
}

// Filter the releases based on their associated tags and only return releases that have at least one matching tag (i.e. OR matching).
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) Tag(tag []string) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.tag = &tag
	return r
}

// Update type filter.
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) UpdateType(updateType string) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.updateType = &updateType
	return r
}

// Starting page.
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) Page(page int32) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.page = &page
	return r
}

// Maximum number of results per page.
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) PerPage(perPage int32) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.perPage = &perPage
	return r
}

// Sort the release list by the specified field and direction. 
func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) Sort(sort string) ApiDeploymentsV2ListReleasesWithPaginationRequest {
	r.sort = &sort
	return r
}

func (r ApiDeploymentsV2ListReleasesWithPaginationRequest) Execute() ([]ReleaseV2, *http.Response, error) {
	return r.ApiService.DeploymentsV2ListReleasesWithPaginationExecute(r)
}

/*
DeploymentsV2ListReleasesWithPagination List releases 

Returns a collection of releases, allows filtering by release name and sorting
by name or last modification date.


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

// Execute executes the request
//  @return []ReleaseV2
func (a *DeploymentsV2ManagementAPIAPIService) DeploymentsV2ListReleasesWithPaginationExecute(r ApiDeploymentsV2ListReleasesWithPaginationRequest) ([]ReleaseV2, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []ReleaseV2
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments/releases"

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

	if r.name != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "")
	}
	if r.tag != nil {
		t := *r.tag
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "tag", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "tag", t, "form", "multi")
		}
	}
	if r.updateType != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "update_type", r.updateType, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	} else {
		var defaultValue int32 = 1
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", defaultValue, "form", "")
		r.page = &defaultValue
	}
	if r.perPage != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", r.perPage, "form", "")
	} else {
		var defaultValue int32 = 20
		parameterAddToHeaderOrQuery(localVarQueryParams, "per_page", defaultValue, "form", "")
		r.perPage = &defaultValue
	}
	if r.sort != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "sort", r.sort, "form", "")
	} else {
		var defaultValue string = "name:asc"
		parameterAddToHeaderOrQuery(localVarQueryParams, "sort", defaultValue, "form", "")
		r.sort = &defaultValue
	}
	// 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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiGetReleaseWithGivenNameRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	releaseName string
}

func (r ApiGetReleaseWithGivenNameRequest) Execute() (*ReleaseV2, *http.Response, error) {
	return r.ApiService.GetReleaseWithGivenNameExecute(r)
}

/*
GetReleaseWithGivenName Get release 

Returns the release with given name.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param releaseName Name of the release
 @return ApiGetReleaseWithGivenNameRequest
*/
func (a *DeploymentsV2ManagementAPIAPIService) GetReleaseWithGivenName(ctx context.Context, releaseName string) ApiGetReleaseWithGivenNameRequest {
	return ApiGetReleaseWithGivenNameRequest{
		ApiService: a,
		ctx: ctx,
		releaseName: releaseName,
	}
}

// Execute executes the request
//  @return ReleaseV2
func (a *DeploymentsV2ManagementAPIAPIService) GetReleaseWithGivenNameExecute(r ApiGetReleaseWithGivenNameRequest) (*ReleaseV2, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *ReleaseV2
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments/releases/{release_name}"
	localVarPath = strings.Replace(localVarPath, "{"+"release_name"+"}", url.PathEscape(parameterValueToString(r.releaseName, "releaseName")), -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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 404 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiListReleaseTagsRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
}

func (r ApiListReleaseTagsRequest) Execute() ([]string, *http.Response, error) {
	return r.ApiService.ListReleaseTagsExecute(r)
}

/*
ListReleaseTags Lists all available tags for releases. 

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

// Execute executes the request
//  @return []string
func (a *DeploymentsV2ManagementAPIAPIService) ListReleaseTagsExecute(r ApiListReleaseTagsRequest) ([]string, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []string
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/releases/all/tags"

	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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 409 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiListReleaseTypesRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
}

func (r ApiListReleaseTypesRequest) Execute() ([]string, *http.Response, error) {
	return r.ApiService.ListReleaseTypesExecute(r)
}

/*
ListReleaseTypes Lists all release update types. 

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

// Execute executes the request
//  @return []string
func (a *DeploymentsV2ManagementAPIAPIService) ListReleaseTypesExecute(r ApiListReleaseTypesRequest) ([]string, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []string
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/releases/all/types"

	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
	}
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarReturnValue, localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarReturnValue, localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarReturnValue, localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		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 ApiUpdateReleaseInformationRequest struct {
	ctx context.Context
	ApiService DeploymentsV2ManagementAPIAPI
	releaseName string
	releaseUpdate *ReleaseUpdate
}

func (r ApiUpdateReleaseInformationRequest) ReleaseUpdate(releaseUpdate ReleaseUpdate) ApiUpdateReleaseInformationRequest {
	r.releaseUpdate = &releaseUpdate
	return r
}

func (r ApiUpdateReleaseInformationRequest) Execute() (*http.Response, error) {
	return r.ApiService.UpdateReleaseInformationExecute(r)
}

/*
UpdateReleaseInformation Update selected fields of the Release object. 

Updates the Release object.


 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param releaseName Name of the release
 @return ApiUpdateReleaseInformationRequest
*/
func (a *DeploymentsV2ManagementAPIAPIService) UpdateReleaseInformation(ctx context.Context, releaseName string) ApiUpdateReleaseInformationRequest {
	return ApiUpdateReleaseInformationRequest{
		ApiService: a,
		ctx: ctx,
		releaseName: releaseName,
	}
}

// Execute executes the request
func (a *DeploymentsV2ManagementAPIAPIService) UpdateReleaseInformationExecute(r ApiUpdateReleaseInformationRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPatch
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/management/v2/deployments/deployments/releases/{release_name}"
	localVarPath = strings.Replace(localVarPath, "{"+"release_name"+"}", url.PathEscape(parameterValueToString(r.releaseName, "releaseName")), -1)

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

	// 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
	}
	// body params
	localVarPostBody = r.releaseUpdate
	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 a.client.cfg.ResponseMiddleware != nil {
		err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
		if err != nil {
			return localVarHTTPResponse, err
		}
	}

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 401 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
			return localVarHTTPResponse, newErr
		}
		if localVarHTTPResponse.StatusCode == 500 {
			var v Error
			err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
			if err != nil {
				newErr.error = err.Error()
				return localVarHTTPResponse, newErr
			}
					newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
					newErr.model = v
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}
