/*
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 DeviceAuthenticationInternalAPIAPI interface {

	/*
	DeviceAuthInternalCheckHealth Check the health of the service

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

	// DeviceAuthInternalCheckHealthExecute executes the request
	DeviceAuthInternalCheckHealthExecute(r ApiDeviceAuthInternalCheckHealthRequest) (*http.Response, error)

	/*
	DeviceAuthInternalCheckLiveliness Trivial endpoint that unconditionally returns an empty 204 response whenever the API handler is running correctly.

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

	// DeviceAuthInternalCheckLivelinessExecute executes the request
	DeviceAuthInternalCheckLivelinessExecute(r ApiDeviceAuthInternalCheckLivelinessRequest) (*http.Response, error)

	/*
	DeviceAuthInternalClearDeviceLimit Remove max device count limit

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

	// DeviceAuthInternalClearDeviceLimitExecute executes the request
	DeviceAuthInternalClearDeviceLimitExecute(r ApiDeviceAuthInternalClearDeviceLimitRequest) (*http.Response, error)

	/*
	DeviceAuthInternalCountDevices Count number of devices, optionally filtered by status.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tid Tenant identifier.
	@return ApiDeviceAuthInternalCountDevicesRequest
	*/
	DeviceAuthInternalCountDevices(ctx context.Context, tid string) ApiDeviceAuthInternalCountDevicesRequest

	// DeviceAuthInternalCountDevicesExecute executes the request
	//  @return Count
	DeviceAuthInternalCountDevicesExecute(r ApiDeviceAuthInternalCountDevicesRequest) (*Count, *http.Response, error)

	/*
	DeviceAuthInternalCreateTenant Provision a new tenant

	Sets up all tenant-related infrastructure, e.g. a migrated tenant's database.

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

	// DeviceAuthInternalCreateTenantExecute executes the request
	DeviceAuthInternalCreateTenantExecute(r ApiDeviceAuthInternalCreateTenantRequest) (*http.Response, error)

	/*
	DeviceAuthInternalDeleteDevice Delete a device from deviceauth service.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tid
	@param did
	@return ApiDeviceAuthInternalDeleteDeviceRequest
	*/
	DeviceAuthInternalDeleteDevice(ctx context.Context, tid string, did string) ApiDeviceAuthInternalDeleteDeviceRequest

	// DeviceAuthInternalDeleteDeviceExecute executes the request
	DeviceAuthInternalDeleteDeviceExecute(r ApiDeviceAuthInternalDeleteDeviceRequest) (*http.Response, error)

	/*
	DeviceAuthInternalDeviceStatus Get the status of a tenant's device

	Returns the overall status of the device, computed over the statuses of its various authsets.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tid Tenant identifier.
	@param did Device identifier.
	@return ApiDeviceAuthInternalDeviceStatusRequest
	*/
	DeviceAuthInternalDeviceStatus(ctx context.Context, tid string, did string) ApiDeviceAuthInternalDeviceStatusRequest

	// DeviceAuthInternalDeviceStatusExecute executes the request
	//  @return Status
	DeviceAuthInternalDeviceStatusExecute(r ApiDeviceAuthInternalDeviceStatusRequest) (*Status, *http.Response, error)

	/*
	DeviceAuthInternalGetDeviceLimit Max device count limit

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

	// DeviceAuthInternalGetDeviceLimitExecute executes the request
	//  @return Limit
	DeviceAuthInternalGetDeviceLimitExecute(r ApiDeviceAuthInternalGetDeviceLimitRequest) (*Limit, *http.Response, error)

	/*
	DeviceAuthInternalListDevices Get a list of tenant's devices.

	Provides a list of tenant's devices, sorted by creation date, with optional device status filter.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tid Tenant identifier.
	@return ApiDeviceAuthInternalListDevicesRequest
	*/
	DeviceAuthInternalListDevices(ctx context.Context, tid string) ApiDeviceAuthInternalListDevicesRequest

	// DeviceAuthInternalListDevicesExecute executes the request
	//  @return []Device
	DeviceAuthInternalListDevicesExecute(r ApiDeviceAuthInternalListDevicesRequest) ([]Device, *http.Response, error)

	/*
	DeviceAuthInternalRevokeDeviceTokens Delete device tokens

	This endpoint is designed to be used for device decommissioning and tenant account suspension purpose. For device decommissioning purpose both tenant_id and device_id parameters must be set. When both tenant_id and device_id parameters are set, all tokens will be deleted for device with given device_id. For tenant account suspension purpose only tenant_id parameter must be set. When device_id parameter is not set (only tenant_id parameter is set) all tokens for all tenant devices will be deleted.

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

	// DeviceAuthInternalRevokeDeviceTokensExecute executes the request
	DeviceAuthInternalRevokeDeviceTokensExecute(r ApiDeviceAuthInternalRevokeDeviceTokensRequest) (*http.Response, error)

	/*
	DeviceAuthInternalSetExternalIdentity Replace the external identity of a device.

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param tid Tenant identifier.
	@param did Device identifier.
	@return ApiDeviceAuthInternalSetExternalIdentityRequest
	*/
	DeviceAuthInternalSetExternalIdentity(ctx context.Context, tid string, did string) ApiDeviceAuthInternalSetExternalIdentityRequest

	// DeviceAuthInternalSetExternalIdentityExecute executes the request
	DeviceAuthInternalSetExternalIdentityExecute(r ApiDeviceAuthInternalSetExternalIdentityRequest) (*http.Response, error)

	/*
	DeviceAuthInternalUpdateDeviceLimit Update max device count limit

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

	// DeviceAuthInternalUpdateDeviceLimitExecute executes the request
	DeviceAuthInternalUpdateDeviceLimitExecute(r ApiDeviceAuthInternalUpdateDeviceLimitRequest) (*http.Response, error)

	/*
	DeviceAuthInternalVerifyJWT Check the validity of a token

	Besides the basic validity check, checks the token expiration time and user-initiated token revocation. Services which intend to use it should be correctly set up in the gateway's configuration.

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

	// DeviceAuthInternalVerifyJWTExecute executes the request
	DeviceAuthInternalVerifyJWTExecute(r ApiDeviceAuthInternalVerifyJWTRequest) (*http.Response, error)
}

// DeviceAuthenticationInternalAPIAPIService DeviceAuthenticationInternalAPIAPI service
type DeviceAuthenticationInternalAPIAPIService service

type ApiDeviceAuthInternalCheckHealthRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
}

func (r ApiDeviceAuthInternalCheckHealthRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalCheckHealthExecute(r)
}

/*
DeviceAuthInternalCheckHealth Check the health of the service

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

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/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 == 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
		}
		if localVarHTTPResponse.StatusCode == 503 {
			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 ApiDeviceAuthInternalCheckLivelinessRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
}

func (r ApiDeviceAuthInternalCheckLivelinessRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalCheckLivelinessExecute(r)
}

/*
DeviceAuthInternalCheckLiveliness Trivial endpoint that unconditionally returns an empty 204 response whenever the API handler is running correctly.

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

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/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 ApiDeviceAuthInternalClearDeviceLimitRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tenantId string
}

func (r ApiDeviceAuthInternalClearDeviceLimitRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalClearDeviceLimitExecute(r)
}

/*
DeviceAuthInternalClearDeviceLimit Remove max device count limit

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId Tenant ID.
 @return ApiDeviceAuthInternalClearDeviceLimitRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalClearDeviceLimit(ctx context.Context, tenantId string) ApiDeviceAuthInternalClearDeviceLimitRequest {
	return ApiDeviceAuthInternalClearDeviceLimitRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenant/{tenant_id}/limits/max_devices"
	localVarPath = strings.Replace(localVarPath, "{"+"tenant_id"+"}", 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 ApiDeviceAuthInternalCountDevicesRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tid string
	status *string
}

// Device status filter, one of &#39;pending&#39;, &#39;accepted&#39;, &#39;rejected&#39;, &#39;noauth&#39;. Default is &#39;all devices&#39;.
func (r ApiDeviceAuthInternalCountDevicesRequest) Status(status string) ApiDeviceAuthInternalCountDevicesRequest {
	r.status = &status
	return r
}

func (r ApiDeviceAuthInternalCountDevicesRequest) Execute() (*Count, *http.Response, error) {
	return r.ApiService.DeviceAuthInternalCountDevicesExecute(r)
}

/*
DeviceAuthInternalCountDevices Count number of devices, optionally filtered by status.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tid Tenant identifier.
 @return ApiDeviceAuthInternalCountDevicesRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalCountDevices(ctx context.Context, tid string) ApiDeviceAuthInternalCountDevicesRequest {
	return ApiDeviceAuthInternalCountDevicesRequest{
		ApiService: a,
		ctx: ctx,
		tid: tid,
	}
}

// Execute executes the request
//  @return Count
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalCountDevicesExecute(r ApiDeviceAuthInternalCountDevicesRequest) (*Count, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *Count
	)

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenants/{tid}/devices/count"
	localVarPath = strings.Replace(localVarPath, "{"+"tid"+"}", url.PathEscape(parameterValueToString(r.tid, "tid")), -1)

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

	if r.status != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "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 == 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 ApiDeviceAuthInternalCreateTenantRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	newTenant *NewTenant
}

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

func (r ApiDeviceAuthInternalCreateTenantRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalCreateTenantExecute(r)
}

/*
DeviceAuthInternalCreateTenant Provision a new tenant

Sets up all tenant-related infrastructure, e.g. a migrated tenant's database.

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

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

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

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

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// 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
}

type ApiDeviceAuthInternalDeleteDeviceRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tid string
	did string
}

func (r ApiDeviceAuthInternalDeleteDeviceRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalDeleteDeviceExecute(r)
}

/*
DeviceAuthInternalDeleteDevice Delete a device from deviceauth service.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tid
 @param did
 @return ApiDeviceAuthInternalDeleteDeviceRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalDeleteDevice(ctx context.Context, tid string, did string) ApiDeviceAuthInternalDeleteDeviceRequest {
	return ApiDeviceAuthInternalDeleteDeviceRequest{
		ApiService: a,
		ctx: ctx,
		tid: tid,
		did: did,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenants/{tid}/devices/{did}"
	localVarPath = strings.Replace(localVarPath, "{"+"tid"+"}", url.PathEscape(parameterValueToString(r.tid, "tid")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"did"+"}", url.PathEscape(parameterValueToString(r.did, "did")), -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 == 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
		}
		if localVarHTTPResponse.StatusCode == 503 {
			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 ApiDeviceAuthInternalDeviceStatusRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tid string
	did string
}

func (r ApiDeviceAuthInternalDeviceStatusRequest) Execute() (*Status, *http.Response, error) {
	return r.ApiService.DeviceAuthInternalDeviceStatusExecute(r)
}

/*
DeviceAuthInternalDeviceStatus Get the status of a tenant's device

Returns the overall status of the device, computed over the statuses of its various authsets.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tid Tenant identifier.
 @param did Device identifier.
 @return ApiDeviceAuthInternalDeviceStatusRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalDeviceStatus(ctx context.Context, tid string, did string) ApiDeviceAuthInternalDeviceStatusRequest {
	return ApiDeviceAuthInternalDeviceStatusRequest{
		ApiService: a,
		ctx: ctx,
		tid: tid,
		did: did,
	}
}

// Execute executes the request
//  @return Status
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalDeviceStatusExecute(r ApiDeviceAuthInternalDeviceStatusRequest) (*Status, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *Status
	)

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

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

func (r ApiDeviceAuthInternalGetDeviceLimitRequest) Execute() (*Limit, *http.Response, error) {
	return r.ApiService.DeviceAuthInternalGetDeviceLimitExecute(r)
}

/*
DeviceAuthInternalGetDeviceLimit Max device count limit

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId Tenant ID.
 @return ApiDeviceAuthInternalGetDeviceLimitRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalGetDeviceLimit(ctx context.Context, tenantId string) ApiDeviceAuthInternalGetDeviceLimitRequest {
	return ApiDeviceAuthInternalGetDeviceLimitRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
	}
}

// Execute executes the request
//  @return Limit
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalGetDeviceLimitExecute(r ApiDeviceAuthInternalGetDeviceLimitRequest) (*Limit, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  *Limit
	)

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenant/{tenant_id}/limits/max_devices"
	localVarPath = strings.Replace(localVarPath, "{"+"tenant_id"+"}", 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 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 == 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 ApiDeviceAuthInternalListDevicesRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tid string
	status *string
	id *[]string
	page *int32
	perPage *int32
}

// Device status filter. If not specified, all devices are listed.
func (r ApiDeviceAuthInternalListDevicesRequest) Status(status string) ApiDeviceAuthInternalListDevicesRequest {
	r.status = &status
	return r
}

// Device ID filter. Can be repeated to query a set of devices.
func (r ApiDeviceAuthInternalListDevicesRequest) Id(id []string) ApiDeviceAuthInternalListDevicesRequest {
	r.id = &id
	return r
}

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

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

func (r ApiDeviceAuthInternalListDevicesRequest) Execute() ([]Device, *http.Response, error) {
	return r.ApiService.DeviceAuthInternalListDevicesExecute(r)
}

/*
DeviceAuthInternalListDevices Get a list of tenant's devices.

Provides a list of tenant's devices, sorted by creation date, with optional device status filter.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tid Tenant identifier.
 @return ApiDeviceAuthInternalListDevicesRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalListDevices(ctx context.Context, tid string) ApiDeviceAuthInternalListDevicesRequest {
	return ApiDeviceAuthInternalListDevicesRequest{
		ApiService: a,
		ctx: ctx,
		tid: tid,
	}
}

// Execute executes the request
//  @return []Device
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalListDevicesExecute(r ApiDeviceAuthInternalListDevicesRequest) ([]Device, *http.Response, error) {
	var (
		localVarHTTPMethod   = http.MethodGet
		localVarPostBody     interface{}
		formFiles            []formFile
		localVarReturnValue  []Device
	)

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenants/{tid}/devices"
	localVarPath = strings.Replace(localVarPath, "{"+"tid"+"}", url.PathEscape(parameterValueToString(r.tid, "tid")), -1)

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

	if r.status != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
	}
	if r.id != nil {
		t := *r.id
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "id", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "id", t, "form", "multi")
		}
	}
	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 == 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 == 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 ApiDeviceAuthInternalRevokeDeviceTokensRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tenantId *string
	deviceId *string
}

func (r ApiDeviceAuthInternalRevokeDeviceTokensRequest) TenantId(tenantId string) ApiDeviceAuthInternalRevokeDeviceTokensRequest {
	r.tenantId = &tenantId
	return r
}

func (r ApiDeviceAuthInternalRevokeDeviceTokensRequest) DeviceId(deviceId string) ApiDeviceAuthInternalRevokeDeviceTokensRequest {
	r.deviceId = &deviceId
	return r
}

func (r ApiDeviceAuthInternalRevokeDeviceTokensRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalRevokeDeviceTokensExecute(r)
}

/*
DeviceAuthInternalRevokeDeviceTokens Delete device tokens

This endpoint is designed to be used for device decommissioning and tenant account suspension purpose. For device decommissioning purpose both tenant_id and device_id parameters must be set. When both tenant_id and device_id parameters are set, all tokens will be deleted for device with given device_id. For tenant account suspension purpose only tenant_id parameter must be set. When device_id parameter is not set (only tenant_id parameter is set) all tokens for all tenant devices will be deleted.

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

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tokens"

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

	parameterAddToHeaderOrQuery(localVarQueryParams, "tenant_id", r.tenantId, "form", "")
	if r.deviceId != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "device_id", r.deviceId, "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 == 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
		}
		if localVarHTTPResponse.StatusCode == 503 {
			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 ApiDeviceAuthInternalSetExternalIdentityRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tid string
	did string
	externalDevice *ExternalDevice
}

func (r ApiDeviceAuthInternalSetExternalIdentityRequest) ExternalDevice(externalDevice ExternalDevice) ApiDeviceAuthInternalSetExternalIdentityRequest {
	r.externalDevice = &externalDevice
	return r
}

func (r ApiDeviceAuthInternalSetExternalIdentityRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalSetExternalIdentityExecute(r)
}

/*
DeviceAuthInternalSetExternalIdentity Replace the external identity of a device.

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tid Tenant identifier.
 @param did Device identifier.
 @return ApiDeviceAuthInternalSetExternalIdentityRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalSetExternalIdentity(ctx context.Context, tid string, did string) ApiDeviceAuthInternalSetExternalIdentityRequest {
	return ApiDeviceAuthInternalSetExternalIdentityRequest{
		ApiService: a,
		ctx: ctx,
		tid: tid,
		did: did,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenants/{tid}/devices/{did}/external"
	localVarPath = strings.Replace(localVarPath, "{"+"tid"+"}", url.PathEscape(parameterValueToString(r.tid, "tid")), -1)
	localVarPath = strings.Replace(localVarPath, "{"+"did"+"}", url.PathEscape(parameterValueToString(r.did, "did")), -1)

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.externalDevice
	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 ApiDeviceAuthInternalUpdateDeviceLimitRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	tenantId string
	limit *Limit
}

func (r ApiDeviceAuthInternalUpdateDeviceLimitRequest) Limit(limit Limit) ApiDeviceAuthInternalUpdateDeviceLimitRequest {
	r.limit = &limit
	return r
}

func (r ApiDeviceAuthInternalUpdateDeviceLimitRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalUpdateDeviceLimitExecute(r)
}

/*
DeviceAuthInternalUpdateDeviceLimit Update max device count limit

 @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
 @param tenantId Tenant ID.
 @return ApiDeviceAuthInternalUpdateDeviceLimitRequest
*/
func (a *DeviceAuthenticationInternalAPIAPIService) DeviceAuthInternalUpdateDeviceLimit(ctx context.Context, tenantId string) ApiDeviceAuthInternalUpdateDeviceLimitRequest {
	return ApiDeviceAuthInternalUpdateDeviceLimitRequest{
		ApiService: a,
		ctx: ctx,
		tenantId: tenantId,
	}
}

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tenant/{tenant_id}/limits/max_devices"
	localVarPath = strings.Replace(localVarPath, "{"+"tenant_id"+"}", url.PathEscape(parameterValueToString(r.tenantId, "tenantId")), -1)

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	// body params
	localVarPostBody = r.limit
	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 ApiDeviceAuthInternalVerifyJWTRequest struct {
	ctx context.Context
	ApiService DeviceAuthenticationInternalAPIAPI
	authorization *string
}

// The token in base64-encoded form.
func (r ApiDeviceAuthInternalVerifyJWTRequest) Authorization(authorization string) ApiDeviceAuthInternalVerifyJWTRequest {
	r.authorization = &authorization
	return r
}

func (r ApiDeviceAuthInternalVerifyJWTRequest) Execute() (*http.Response, error) {
	return r.ApiService.DeviceAuthInternalVerifyJWTExecute(r)
}

/*
DeviceAuthInternalVerifyJWT Check the validity of a token

Besides the basic validity check, checks the token expiration time and user-initiated token revocation. Services which intend to use it should be correctly set up in the gateway's configuration.

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

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

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

	localVarPath := localBasePath + "/api/internal/v1/devauth/tokens/verify"

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

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

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

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

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
	parameterAddToHeaderOrQuery(localVarHeaderParams, "Authorization", r.authorization, "simple", "")
	req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
	if err != nil {
		return nil, err
	}

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

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

	if 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 == 403 {
			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
		}
		if localVarHTTPResponse.StatusCode == 503 {
			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
}
