/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

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

package api

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

// CoreAPIService CoreAPI service
type CoreAPIService service

type ApiCoreBrandsListRequest struct {
	ctx                           context.Context
	ApiService                    *CoreAPIService
	brandUuid                     *string
	brandingDefaultFlowBackground *string
	brandingFavicon               *string
	brandingLogo                  *string
	brandingTitle                 *string
	clientCertificates            *[]string
	default_                      *bool
	domain                        *string
	flowAuthentication            *string
	flowDeviceCode                *string
	flowInvalidation              *string
	flowRecovery                  *string
	flowUnenrollment              *string
	flowUserSettings              *string
	ordering                      *string
	page                          *int32
	pageSize                      *int32
	search                        *string
	webCertificate                *string
}

func (r ApiCoreBrandsListRequest) BrandUuid(brandUuid string) ApiCoreBrandsListRequest {
	r.brandUuid = &brandUuid
	return r
}

func (r ApiCoreBrandsListRequest) BrandingDefaultFlowBackground(brandingDefaultFlowBackground string) ApiCoreBrandsListRequest {
	r.brandingDefaultFlowBackground = &brandingDefaultFlowBackground
	return r
}

func (r ApiCoreBrandsListRequest) BrandingFavicon(brandingFavicon string) ApiCoreBrandsListRequest {
	r.brandingFavicon = &brandingFavicon
	return r
}

func (r ApiCoreBrandsListRequest) BrandingLogo(brandingLogo string) ApiCoreBrandsListRequest {
	r.brandingLogo = &brandingLogo
	return r
}

func (r ApiCoreBrandsListRequest) BrandingTitle(brandingTitle string) ApiCoreBrandsListRequest {
	r.brandingTitle = &brandingTitle
	return r
}

func (r ApiCoreBrandsListRequest) ClientCertificates(clientCertificates []string) ApiCoreBrandsListRequest {
	r.clientCertificates = &clientCertificates
	return r
}

func (r ApiCoreBrandsListRequest) Default_(default_ bool) ApiCoreBrandsListRequest {
	r.default_ = &default_
	return r
}

func (r ApiCoreBrandsListRequest) Domain(domain string) ApiCoreBrandsListRequest {
	r.domain = &domain
	return r
}

func (r ApiCoreBrandsListRequest) FlowAuthentication(flowAuthentication string) ApiCoreBrandsListRequest {
	r.flowAuthentication = &flowAuthentication
	return r
}

func (r ApiCoreBrandsListRequest) FlowDeviceCode(flowDeviceCode string) ApiCoreBrandsListRequest {
	r.flowDeviceCode = &flowDeviceCode
	return r
}

func (r ApiCoreBrandsListRequest) FlowInvalidation(flowInvalidation string) ApiCoreBrandsListRequest {
	r.flowInvalidation = &flowInvalidation
	return r
}

func (r ApiCoreBrandsListRequest) FlowRecovery(flowRecovery string) ApiCoreBrandsListRequest {
	r.flowRecovery = &flowRecovery
	return r
}

func (r ApiCoreBrandsListRequest) FlowUnenrollment(flowUnenrollment string) ApiCoreBrandsListRequest {
	r.flowUnenrollment = &flowUnenrollment
	return r
}

func (r ApiCoreBrandsListRequest) FlowUserSettings(flowUserSettings string) ApiCoreBrandsListRequest {
	r.flowUserSettings = &flowUserSettings
	return r
}

// Which field to use when ordering the results.
func (r ApiCoreBrandsListRequest) Ordering(ordering string) ApiCoreBrandsListRequest {
	r.ordering = &ordering
	return r
}

// A page number within the paginated result set.
func (r ApiCoreBrandsListRequest) Page(page int32) ApiCoreBrandsListRequest {
	r.page = &page
	return r
}

// Number of results to return per page.
func (r ApiCoreBrandsListRequest) PageSize(pageSize int32) ApiCoreBrandsListRequest {
	r.pageSize = &pageSize
	return r
}

// A search term.
func (r ApiCoreBrandsListRequest) Search(search string) ApiCoreBrandsListRequest {
	r.search = &search
	return r
}

func (r ApiCoreBrandsListRequest) WebCertificate(webCertificate string) ApiCoreBrandsListRequest {
	r.webCertificate = &webCertificate
	return r
}

func (r ApiCoreBrandsListRequest) Execute() (*PaginatedBrandList, *http.Response, error) {
	return r.ApiService.CoreBrandsListExecute(r)
}

/*
CoreBrandsList Method for CoreBrandsList

Brand Viewset

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

// Execute executes the request
//
//	@return PaginatedBrandList
func (a *CoreAPIService) CoreBrandsListExecute(r ApiCoreBrandsListRequest) (*PaginatedBrandList, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *PaginatedBrandList
	)

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

	localVarPath := localBasePath + "/core/brands/"

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

	if r.brandUuid != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "brand_uuid", r.brandUuid, "form", "")
	}
	if r.brandingDefaultFlowBackground != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "branding_default_flow_background", r.brandingDefaultFlowBackground, "form", "")
	}
	if r.brandingFavicon != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "branding_favicon", r.brandingFavicon, "form", "")
	}
	if r.brandingLogo != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "branding_logo", r.brandingLogo, "form", "")
	}
	if r.brandingTitle != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "branding_title", r.brandingTitle, "form", "")
	}
	if r.clientCertificates != nil {
		t := *r.clientCertificates
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "client_certificates", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "client_certificates", t, "form", "multi")
		}
	}
	if r.default_ != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "default", r.default_, "form", "")
	}
	if r.domain != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "domain", r.domain, "form", "")
	}
	if r.flowAuthentication != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_authentication", r.flowAuthentication, "form", "")
	}
	if r.flowDeviceCode != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_device_code", r.flowDeviceCode, "form", "")
	}
	if r.flowInvalidation != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_invalidation", r.flowInvalidation, "form", "")
	}
	if r.flowRecovery != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_recovery", r.flowRecovery, "form", "")
	}
	if r.flowUnenrollment != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_unenrollment", r.flowUnenrollment, "form", "")
	}
	if r.flowUserSettings != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "flow_user_settings", r.flowUserSettings, "form", "")
	}
	if r.ordering != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "ordering", r.ordering, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	}
	if r.pageSize != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page_size", r.pageSize, "form", "")
	}
	if r.search != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "form", "")
	}
	if r.webCertificate != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "web_certificate", r.webCertificate, "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 localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v ValidationError
			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 == 403 {
			var v GenericError
			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 ApiCoreGroupsListRequest struct {
	ctx                   context.Context
	ApiService            *CoreAPIService
	attributes            *string
	includeChildren       *bool
	includeInheritedRoles *bool
	includeParents        *bool
	includeUsers          *bool
	isSuperuser           *bool
	membersByPk           *[]int32
	membersByUsername     *[]string
	name                  *string
	ordering              *string
	page                  *int32
	pageSize              *int32
	search                *string
}

// Attributes
func (r ApiCoreGroupsListRequest) Attributes(attributes string) ApiCoreGroupsListRequest {
	r.attributes = &attributes
	return r
}

func (r ApiCoreGroupsListRequest) IncludeChildren(includeChildren bool) ApiCoreGroupsListRequest {
	r.includeChildren = &includeChildren
	return r
}

func (r ApiCoreGroupsListRequest) IncludeInheritedRoles(includeInheritedRoles bool) ApiCoreGroupsListRequest {
	r.includeInheritedRoles = &includeInheritedRoles
	return r
}

func (r ApiCoreGroupsListRequest) IncludeParents(includeParents bool) ApiCoreGroupsListRequest {
	r.includeParents = &includeParents
	return r
}

func (r ApiCoreGroupsListRequest) IncludeUsers(includeUsers bool) ApiCoreGroupsListRequest {
	r.includeUsers = &includeUsers
	return r
}

func (r ApiCoreGroupsListRequest) IsSuperuser(isSuperuser bool) ApiCoreGroupsListRequest {
	r.isSuperuser = &isSuperuser
	return r
}

func (r ApiCoreGroupsListRequest) MembersByPk(membersByPk []int32) ApiCoreGroupsListRequest {
	r.membersByPk = &membersByPk
	return r
}

// Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
func (r ApiCoreGroupsListRequest) MembersByUsername(membersByUsername []string) ApiCoreGroupsListRequest {
	r.membersByUsername = &membersByUsername
	return r
}

func (r ApiCoreGroupsListRequest) Name(name string) ApiCoreGroupsListRequest {
	r.name = &name
	return r
}

// Which field to use when ordering the results.
func (r ApiCoreGroupsListRequest) Ordering(ordering string) ApiCoreGroupsListRequest {
	r.ordering = &ordering
	return r
}

// A page number within the paginated result set.
func (r ApiCoreGroupsListRequest) Page(page int32) ApiCoreGroupsListRequest {
	r.page = &page
	return r
}

// Number of results to return per page.
func (r ApiCoreGroupsListRequest) PageSize(pageSize int32) ApiCoreGroupsListRequest {
	r.pageSize = &pageSize
	return r
}

// A search term.
func (r ApiCoreGroupsListRequest) Search(search string) ApiCoreGroupsListRequest {
	r.search = &search
	return r
}

func (r ApiCoreGroupsListRequest) Execute() (*PaginatedGroupList, *http.Response, error) {
	return r.ApiService.CoreGroupsListExecute(r)
}

/*
CoreGroupsList Method for CoreGroupsList

Group Viewset

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

// Execute executes the request
//
//	@return PaginatedGroupList
func (a *CoreAPIService) CoreGroupsListExecute(r ApiCoreGroupsListRequest) (*PaginatedGroupList, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *PaginatedGroupList
	)

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

	localVarPath := localBasePath + "/core/groups/"

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

	if r.attributes != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "attributes", r.attributes, "form", "")
	}
	if r.includeChildren != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_children", r.includeChildren, "form", "")
	} else {
		var defaultValue bool = false
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_children", defaultValue, "form", "")
		r.includeChildren = &defaultValue
	}
	if r.includeInheritedRoles != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_inherited_roles", r.includeInheritedRoles, "form", "")
	} else {
		var defaultValue bool = false
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_inherited_roles", defaultValue, "form", "")
		r.includeInheritedRoles = &defaultValue
	}
	if r.includeParents != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_parents", r.includeParents, "form", "")
	} else {
		var defaultValue bool = false
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_parents", defaultValue, "form", "")
		r.includeParents = &defaultValue
	}
	if r.includeUsers != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_users", r.includeUsers, "form", "")
	} else {
		var defaultValue bool = true
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_users", defaultValue, "form", "")
		r.includeUsers = &defaultValue
	}
	if r.isSuperuser != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "is_superuser", r.isSuperuser, "form", "")
	}
	if r.membersByPk != nil {
		t := *r.membersByPk
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "members_by_pk", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "members_by_pk", t, "form", "multi")
		}
	}
	if r.membersByUsername != nil {
		t := *r.membersByUsername
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "members_by_username", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "members_by_username", t, "form", "multi")
		}
	}
	if r.name != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "")
	}
	if r.ordering != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "ordering", r.ordering, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	}
	if r.pageSize != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page_size", r.pageSize, "form", "")
	}
	if r.search != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "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 localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v ValidationError
			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 == 403 {
			var v GenericError
			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 ApiCoreUsersListRequest struct {
	ctx             context.Context
	ApiService      *CoreAPIService
	attributes      *string
	dateJoined      *time.Time
	dateJoinedGt    *time.Time
	dateJoinedLt    *time.Time
	email           *string
	groupsByName    *[]string
	groupsByPk      *[]string
	includeGroups   *bool
	includeRoles    *bool
	isActive        *bool
	isSuperuser     *bool
	lastLogin       *time.Time
	lastLoginGt     *time.Time
	lastLoginIsnull *bool
	lastLoginLt     *time.Time
	lastUpdated     *time.Time
	lastUpdatedGt   *time.Time
	lastUpdatedLt   *time.Time
	name            *string
	ordering        *string
	page            *int32
	pageSize        *int32
	path            *string
	pathStartswith  *string
	rolesByName     *[]string
	rolesByPk       *[]string
	search          *string
	type_           *[]UserTypeEnum
	username        *string
	uuid            *string
}

// Attributes
func (r ApiCoreUsersListRequest) Attributes(attributes string) ApiCoreUsersListRequest {
	r.attributes = &attributes
	return r
}

func (r ApiCoreUsersListRequest) DateJoined(dateJoined time.Time) ApiCoreUsersListRequest {
	r.dateJoined = &dateJoined
	return r
}

func (r ApiCoreUsersListRequest) DateJoinedGt(dateJoinedGt time.Time) ApiCoreUsersListRequest {
	r.dateJoinedGt = &dateJoinedGt
	return r
}

func (r ApiCoreUsersListRequest) DateJoinedLt(dateJoinedLt time.Time) ApiCoreUsersListRequest {
	r.dateJoinedLt = &dateJoinedLt
	return r
}

func (r ApiCoreUsersListRequest) Email(email string) ApiCoreUsersListRequest {
	r.email = &email
	return r
}

func (r ApiCoreUsersListRequest) GroupsByName(groupsByName []string) ApiCoreUsersListRequest {
	r.groupsByName = &groupsByName
	return r
}

func (r ApiCoreUsersListRequest) GroupsByPk(groupsByPk []string) ApiCoreUsersListRequest {
	r.groupsByPk = &groupsByPk
	return r
}

func (r ApiCoreUsersListRequest) IncludeGroups(includeGroups bool) ApiCoreUsersListRequest {
	r.includeGroups = &includeGroups
	return r
}

func (r ApiCoreUsersListRequest) IncludeRoles(includeRoles bool) ApiCoreUsersListRequest {
	r.includeRoles = &includeRoles
	return r
}

func (r ApiCoreUsersListRequest) IsActive(isActive bool) ApiCoreUsersListRequest {
	r.isActive = &isActive
	return r
}

func (r ApiCoreUsersListRequest) IsSuperuser(isSuperuser bool) ApiCoreUsersListRequest {
	r.isSuperuser = &isSuperuser
	return r
}

func (r ApiCoreUsersListRequest) LastLogin(lastLogin time.Time) ApiCoreUsersListRequest {
	r.lastLogin = &lastLogin
	return r
}

func (r ApiCoreUsersListRequest) LastLoginGt(lastLoginGt time.Time) ApiCoreUsersListRequest {
	r.lastLoginGt = &lastLoginGt
	return r
}

func (r ApiCoreUsersListRequest) LastLoginIsnull(lastLoginIsnull bool) ApiCoreUsersListRequest {
	r.lastLoginIsnull = &lastLoginIsnull
	return r
}

func (r ApiCoreUsersListRequest) LastLoginLt(lastLoginLt time.Time) ApiCoreUsersListRequest {
	r.lastLoginLt = &lastLoginLt
	return r
}

func (r ApiCoreUsersListRequest) LastUpdated(lastUpdated time.Time) ApiCoreUsersListRequest {
	r.lastUpdated = &lastUpdated
	return r
}

func (r ApiCoreUsersListRequest) LastUpdatedGt(lastUpdatedGt time.Time) ApiCoreUsersListRequest {
	r.lastUpdatedGt = &lastUpdatedGt
	return r
}

func (r ApiCoreUsersListRequest) LastUpdatedLt(lastUpdatedLt time.Time) ApiCoreUsersListRequest {
	r.lastUpdatedLt = &lastUpdatedLt
	return r
}

func (r ApiCoreUsersListRequest) Name(name string) ApiCoreUsersListRequest {
	r.name = &name
	return r
}

// Which field to use when ordering the results.
func (r ApiCoreUsersListRequest) Ordering(ordering string) ApiCoreUsersListRequest {
	r.ordering = &ordering
	return r
}

// A page number within the paginated result set.
func (r ApiCoreUsersListRequest) Page(page int32) ApiCoreUsersListRequest {
	r.page = &page
	return r
}

// Number of results to return per page.
func (r ApiCoreUsersListRequest) PageSize(pageSize int32) ApiCoreUsersListRequest {
	r.pageSize = &pageSize
	return r
}

func (r ApiCoreUsersListRequest) Path(path string) ApiCoreUsersListRequest {
	r.path = &path
	return r
}

func (r ApiCoreUsersListRequest) PathStartswith(pathStartswith string) ApiCoreUsersListRequest {
	r.pathStartswith = &pathStartswith
	return r
}

func (r ApiCoreUsersListRequest) RolesByName(rolesByName []string) ApiCoreUsersListRequest {
	r.rolesByName = &rolesByName
	return r
}

func (r ApiCoreUsersListRequest) RolesByPk(rolesByPk []string) ApiCoreUsersListRequest {
	r.rolesByPk = &rolesByPk
	return r
}

// A search term.
func (r ApiCoreUsersListRequest) Search(search string) ApiCoreUsersListRequest {
	r.search = &search
	return r
}

func (r ApiCoreUsersListRequest) Type_(type_ []UserTypeEnum) ApiCoreUsersListRequest {
	r.type_ = &type_
	return r
}

func (r ApiCoreUsersListRequest) Username(username string) ApiCoreUsersListRequest {
	r.username = &username
	return r
}

func (r ApiCoreUsersListRequest) Uuid(uuid string) ApiCoreUsersListRequest {
	r.uuid = &uuid
	return r
}

func (r ApiCoreUsersListRequest) Execute() (*PaginatedUserList, *http.Response, error) {
	return r.ApiService.CoreUsersListExecute(r)
}

/*
CoreUsersList Method for CoreUsersList

User Viewset

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

// Execute executes the request
//
//	@return PaginatedUserList
func (a *CoreAPIService) CoreUsersListExecute(r ApiCoreUsersListRequest) (*PaginatedUserList, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *PaginatedUserList
	)

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

	localVarPath := localBasePath + "/core/users/"

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

	if r.attributes != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "attributes", r.attributes, "form", "")
	}
	if r.dateJoined != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "date_joined", r.dateJoined, "form", "")
	}
	if r.dateJoinedGt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "date_joined__gt", r.dateJoinedGt, "form", "")
	}
	if r.dateJoinedLt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "date_joined__lt", r.dateJoinedLt, "form", "")
	}
	if r.email != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "email", r.email, "form", "")
	}
	if r.groupsByName != nil {
		t := *r.groupsByName
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "groups_by_name", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "groups_by_name", t, "form", "multi")
		}
	}
	if r.groupsByPk != nil {
		t := *r.groupsByPk
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "groups_by_pk", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "groups_by_pk", t, "form", "multi")
		}
	}
	if r.includeGroups != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_groups", r.includeGroups, "form", "")
	} else {
		var defaultValue bool = true
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_groups", defaultValue, "form", "")
		r.includeGroups = &defaultValue
	}
	if r.includeRoles != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_roles", r.includeRoles, "form", "")
	} else {
		var defaultValue bool = true
		parameterAddToHeaderOrQuery(localVarQueryParams, "include_roles", defaultValue, "form", "")
		r.includeRoles = &defaultValue
	}
	if r.isActive != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "is_active", r.isActive, "form", "")
	}
	if r.isSuperuser != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "is_superuser", r.isSuperuser, "form", "")
	}
	if r.lastLogin != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_login", r.lastLogin, "form", "")
	}
	if r.lastLoginGt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_login__gt", r.lastLoginGt, "form", "")
	}
	if r.lastLoginIsnull != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_login__isnull", r.lastLoginIsnull, "form", "")
	}
	if r.lastLoginLt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_login__lt", r.lastLoginLt, "form", "")
	}
	if r.lastUpdated != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_updated", r.lastUpdated, "form", "")
	}
	if r.lastUpdatedGt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_updated__gt", r.lastUpdatedGt, "form", "")
	}
	if r.lastUpdatedLt != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "last_updated__lt", r.lastUpdatedLt, "form", "")
	}
	if r.name != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "")
	}
	if r.ordering != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "ordering", r.ordering, "form", "")
	}
	if r.page != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "form", "")
	}
	if r.pageSize != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "page_size", r.pageSize, "form", "")
	}
	if r.path != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "path", r.path, "form", "")
	}
	if r.pathStartswith != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "path_startswith", r.pathStartswith, "form", "")
	}
	if r.rolesByName != nil {
		t := *r.rolesByName
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "roles_by_name", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "roles_by_name", t, "form", "multi")
		}
	}
	if r.rolesByPk != nil {
		t := *r.rolesByPk
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "roles_by_pk", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "roles_by_pk", t, "form", "multi")
		}
	}
	if r.search != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "form", "")
	}
	if r.type_ != nil {
		t := *r.type_
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				parameterAddToHeaderOrQuery(localVarQueryParams, "type", s.Index(i).Interface(), "form", "multi")
			}
		} else {
			parameterAddToHeaderOrQuery(localVarQueryParams, "type", t, "form", "multi")
		}
	}
	if r.username != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "username", r.username, "form", "")
	}
	if r.uuid != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "uuid", r.uuid, "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 localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v ValidationError
			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 == 403 {
			var v GenericError
			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 ApiCoreUsersMeRetrieveRequest struct {
	ctx        context.Context
	ApiService *CoreAPIService
}

func (r ApiCoreUsersMeRetrieveRequest) Execute() (*SessionUser, *http.Response, error) {
	return r.ApiService.CoreUsersMeRetrieveExecute(r)
}

/*
CoreUsersMeRetrieve Method for CoreUsersMeRetrieve

Get information about current user

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

// Execute executes the request
//
//	@return SessionUser
func (a *CoreAPIService) CoreUsersMeRetrieveExecute(r ApiCoreUsersMeRetrieveRequest) (*SessionUser, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *SessionUser
	)

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

	localVarPath := localBasePath + "/core/users/me/"

	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 localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v ValidationError
			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 == 403 {
			var v GenericError
			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 ApiCoreUsersRetrieveRequest struct {
	ctx        context.Context
	ApiService *CoreAPIService
	id         int32
}

func (r ApiCoreUsersRetrieveRequest) Execute() (*User, *http.Response, error) {
	return r.ApiService.CoreUsersRetrieveExecute(r)
}

/*
CoreUsersRetrieve Method for CoreUsersRetrieve

User Viewset

	@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
	@param id A unique integer value identifying this User.
	@return ApiCoreUsersRetrieveRequest
*/
func (a *CoreAPIService) CoreUsersRetrieve(ctx context.Context, id int32) ApiCoreUsersRetrieveRequest {
	return ApiCoreUsersRetrieveRequest{
		ApiService: a,
		ctx:        ctx,
		id:         id,
	}
}

// Execute executes the request
//
//	@return User
func (a *CoreAPIService) CoreUsersRetrieveExecute(r ApiCoreUsersRetrieveRequest) (*User, *http.Response, error) {
	var (
		localVarHTTPMethod  = http.MethodGet
		localVarPostBody    interface{}
		formFiles           []formFile
		localVarReturnValue *User
	)

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

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

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

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

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

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

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

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

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

	if localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		if localVarHTTPResponse.StatusCode == 400 {
			var v ValidationError
			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 == 403 {
			var v GenericError
			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
}
