/*
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"
)


type DeviceConfigureInternalAPIAPI interface {

	/*
	DeviceConfigInternalCheckHealth Get health status of service

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

	// DeviceConfigInternalCheckHealthExecute executes the request
	DeviceConfigInternalCheckHealthExecute(r ApiDeviceConfigInternalCheckHealthRequest) (*http.Response, error)

	/*
	DeviceConfigInternalCheckLiveliness Get service liveliness status.

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

	// DeviceConfigInternalCheckLivelinessExecute executes the request
	DeviceConfigInternalCheckLivelinessExecute(r ApiDeviceConfigInternalCheckLivelinessRequest) (*http.Response, error)

	/*
	DeviceConfigInternalDecommissionDevice Remove a device from the deviceconfig service.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tenantId ID of tenant the device belongs to.
	@param deviceId ID of the target device.
	@return ApiDeviceConfigInternalDecommissionDeviceRequest
	*/
	DeviceConfigInternalDecommissionDevice(ctx context.Context, tenantId string, deviceId string) ApiDeviceConfigInternalDecommissionDeviceRequest

	// DeviceConfigInternalDecommissionDeviceExecute executes the request
	DeviceConfigInternalDecommissionDeviceExecute(r ApiDeviceConfigInternalDecommissionDeviceRequest) (*http.Response, error)

	/*
	DeviceConfigInternalDeleteTenant Delete all the data for given tenant.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tenantId ID of tenant.
	@return ApiDeviceConfigInternalDeleteTenantRequest
	*/
	DeviceConfigInternalDeleteTenant(ctx context.Context, tenantId string) ApiDeviceConfigInternalDeleteTenantRequest

	// DeviceConfigInternalDeleteTenantExecute executes the request
	DeviceConfigInternalDeleteTenantExecute(r ApiDeviceConfigInternalDeleteTenantRequest) (*http.Response, error)

	/*
	DeviceConfigInternalDeployDeviceConfiguration Deploy the device's configuration

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param deviceId ID of the device.
	@param tenantId ID of the tenant.
	@return ApiDeviceConfigInternalDeployDeviceConfigurationRequest
	*/
	DeviceConfigInternalDeployDeviceConfiguration(ctx context.Context, deviceId string, tenantId string) ApiDeviceConfigInternalDeployDeviceConfigurationRequest

	// DeviceConfigInternalDeployDeviceConfigurationExecute executes the request
	//  @return NewConfigurationDeploymentResponse
	DeviceConfigInternalDeployDeviceConfigurationExecute(r ApiDeviceConfigInternalDeployDeviceConfigurationRequest) (*NewConfigurationDeploymentResponse, *http.Response, error)

	/*
	DeviceConfigInternalProvisionDevice Register a new device with the deviceconfig service.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tenantId ID of tenant the device belongs to.
	@return ApiDeviceConfigInternalProvisionDeviceRequest
	*/
	DeviceConfigInternalProvisionDevice(ctx context.Context, tenantId string) ApiDeviceConfigInternalProvisionDeviceRequest

	// DeviceConfigInternalProvisionDeviceExecute executes the request
	DeviceConfigInternalProvisionDeviceExecute(r ApiDeviceConfigInternalProvisionDeviceRequest) (*http.Response, error)

	/*
	DeviceConfigInternalProvisionTenant Initialize internal state for a new tenant

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

	// DeviceConfigInternalProvisionTenantExecute executes the request
	DeviceConfigInternalProvisionTenantExecute(r ApiDeviceConfigInternalProvisionTenantRequest) (*http.Response, error)
}

// DeviceConfigureInternalAPIAPIService DeviceConfigureInternalAPIAPI service
type DeviceConfigureInternalAPIAPIService service

type ApiDeviceConfigInternalCheckHealthRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
}

func (r ApiDeviceConfigInternalCheckHealthRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalCheckHealthExecute(r)
}

/*
DeviceConfigInternalCheckHealth Get health status of service

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

// Execute executes the request
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalCheckHealthExecute(r ApiDeviceConfigInternalCheckHealthRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/health"

	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 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 == 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 ApiDeviceConfigInternalCheckLivelinessRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
}

func (r ApiDeviceConfigInternalCheckLivelinessRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalCheckLivelinessExecute(r)
}

/*
DeviceConfigInternalCheckLiveliness Get service liveliness status.

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

// Execute executes the request
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalCheckLivelinessExecute(r ApiDeviceConfigInternalCheckLivelinessRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/alive"

	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 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 == 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 ApiDeviceConfigInternalDecommissionDeviceRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
	tenantId string
	deviceId string
}

func (r ApiDeviceConfigInternalDecommissionDeviceRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalDecommissionDeviceExecute(r)
}

/*
DeviceConfigInternalDecommissionDevice Remove a device from the deviceconfig service.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId ID of tenant the device belongs to.
 @param deviceId ID of the target device.
 @return ApiDeviceConfigInternalDecommissionDeviceRequest
*/
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalDecommissionDevice(ctx context.Context, tenantId string, deviceId string) ApiDeviceConfigInternalDecommissionDeviceRequest {
	return ApiDeviceConfigInternalDecommissionDeviceRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
		deviceId: deviceId,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/tenants/{tenantId}/devices/{deviceId}"
	localVarPath = strings.Replace(localVarPath, "{"+"tenantId"+"}", url.PathEscape(parameterValueToString(r.tenantId, "tenantId")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"deviceId"+"}", url.PathEscape(parameterValueToString(r.deviceId, "deviceId")), -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 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 == 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 ApiDeviceConfigInternalDeleteTenantRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
	tenantId string
}

func (r ApiDeviceConfigInternalDeleteTenantRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalDeleteTenantExecute(r)
}

/*
DeviceConfigInternalDeleteTenant Delete all the data for given tenant.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId ID of tenant.
 @return ApiDeviceConfigInternalDeleteTenantRequest
*/
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalDeleteTenant(ctx context.Context, tenantId string) ApiDeviceConfigInternalDeleteTenantRequest {
	return ApiDeviceConfigInternalDeleteTenantRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/tenants/{tenantId}"
	localVarPath = strings.Replace(localVarPath, "{"+"tenantId"+"}", url.PathEscape(parameterValueToString(r.tenantId, "tenantId")), -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 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 == 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 ApiDeviceConfigInternalDeployDeviceConfigurationRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
	deviceId string
	tenantId string
	newConfigurationDeployment *NewConfigurationDeployment
}

func (r ApiDeviceConfigInternalDeployDeviceConfigurationRequest) NewConfigurationDeployment(newConfigurationDeployment NewConfigurationDeployment) ApiDeviceConfigInternalDeployDeviceConfigurationRequest {
	r.newConfigurationDeployment = &newConfigurationDeployment
	return r
}

func (r ApiDeviceConfigInternalDeployDeviceConfigurationRequest) Execute() (*NewConfigurationDeploymentResponse, *http.Response, error) {
	return r.ApiService.DeviceConfigInternalDeployDeviceConfigurationExecute(r)
}

/*
DeviceConfigInternalDeployDeviceConfiguration Deploy the device's configuration

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param deviceId ID of the device.
 @param tenantId ID of the tenant.
 @return ApiDeviceConfigInternalDeployDeviceConfigurationRequest
*/
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalDeployDeviceConfiguration(ctx context.Context, deviceId string, tenantId string) ApiDeviceConfigInternalDeployDeviceConfigurationRequest {
	return ApiDeviceConfigInternalDeployDeviceConfigurationRequest{
		ApiService: a,
		ctx: ctx,
		deviceId: deviceId,
		tenantId: tenantId,
	}
}

// Execute executes the request
//  @return NewConfigurationDeploymentResponse
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalDeployDeviceConfigurationExecute(r ApiDeviceConfigInternalDeployDeviceConfigurationRequest) (*NewConfigurationDeploymentResponse, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPost
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *NewConfigurationDeploymentResponse
	)

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/tenants/{tenantId}/configurations/device/{deviceId}/deploy"
	localVarPath = strings.Replace(localVarPath, "{"+"deviceId"+"}", url.PathEscape(parameterValueToString(r.deviceId, "deviceId")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"tenantId"+"}", url.PathEscape(parameterValueToString(r.tenantId, "tenantId")), -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.newConfigurationDeployment
	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 == 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 ApiDeviceConfigInternalProvisionDeviceRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
	tenantId string
	provisionDevice *ProvisionDevice
}

func (r ApiDeviceConfigInternalProvisionDeviceRequest) ProvisionDevice(provisionDevice ProvisionDevice) ApiDeviceConfigInternalProvisionDeviceRequest {
	r.provisionDevice = &provisionDevice
	return r
}

func (r ApiDeviceConfigInternalProvisionDeviceRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalProvisionDeviceExecute(r)
}

/*
DeviceConfigInternalProvisionDevice Register a new device with the deviceconfig service.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId ID of tenant the device belongs to.
 @return ApiDeviceConfigInternalProvisionDeviceRequest
*/
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalProvisionDevice(ctx context.Context, tenantId string) ApiDeviceConfigInternalProvisionDeviceRequest {
	return ApiDeviceConfigInternalProvisionDeviceRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
	}
}

// Execute executes the request
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalProvisionDeviceExecute(r ApiDeviceConfigInternalProvisionDeviceRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPost
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/tenants/{tenantId}/devices"
	localVarPath = strings.Replace(localVarPath, "{"+"tenantId"+"}", url.PathEscape(parameterValueToString(r.tenantId, "tenantId")), -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.provisionDevice
	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 == 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 ApiDeviceConfigInternalProvisionTenantRequest struct {
	ctx context.Context
	ApiService DeviceConfigureInternalAPIAPI
	newTenant *NewTenant
}

func (r ApiDeviceConfigInternalProvisionTenantRequest) NewTenant(newTenant NewTenant) ApiDeviceConfigInternalProvisionTenantRequest {
	r.newTenant = &newTenant
	return r
}

func (r ApiDeviceConfigInternalProvisionTenantRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceConfigInternalProvisionTenantExecute(r)
}

/*
DeviceConfigInternalProvisionTenant Initialize internal state for a new tenant

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

// Execute executes the request
func (a *DeviceConfigureInternalAPIAPIService) DeviceConfigInternalProvisionTenantExecute(r ApiDeviceConfigInternalProvisionTenantRequest) (*http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodPost
		localVarPostBody     interface{}
		formFiles            []formFile
	)

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

	localVarPath := localBasePath + "/api/internal/v1/deviceconfig/tenants"

	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.newTenant
	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 == 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
}
