Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

4.9 KB
Raw Blame
/*
BoxLite

BoxLite AI platform API Docs

API version: 1.0
Contact: [email protected]
*/

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

package apiclient

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


type AuthAPI interface {

	/*
	LogoutControllerEndSession OIDC RP-initiated logout endpoint

	Implements OpenID Connect RP-Initiated Logout 1.0 for IdPs (e.g. Dex) that do not natively advertise end_session_endpoint. Validates the post-logout redirect target, then 302-redirects the browser back to the SPA.

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

	// LogoutControllerEndSessionExecute executes the request
	LogoutControllerEndSessionExecute(r AuthAPILogoutControllerEndSessionRequest) (*http.Response, error)
}

// AuthAPIService AuthAPI service
type AuthAPIService service

type AuthAPILogoutControllerEndSessionRequest struct {
	ctx context.Context
	ApiService AuthAPI
	postLogoutRedirectUri *string
	idTokenHint *string
	state *string
}

func (r AuthAPILogoutControllerEndSessionRequest) PostLogoutRedirectUri(postLogoutRedirectUri string) AuthAPILogoutControllerEndSessionRequest {
	r.postLogoutRedirectUri = &postLogoutRedirectUri
	return r
}

func (r AuthAPILogoutControllerEndSessionRequest) IdTokenHint(idTokenHint string) AuthAPILogoutControllerEndSessionRequest {
	r.idTokenHint = &idTokenHint
	return r
}

func (r AuthAPILogoutControllerEndSessionRequest) State(state string) AuthAPILogoutControllerEndSessionRequest {
	r.state = &state
	return r
}

func (r AuthAPILogoutControllerEndSessionRequest) Execute() (*http.Response, error) {
	return r.ApiService.LogoutControllerEndSessionExecute(r)
}

/*
LogoutControllerEndSession OIDC RP-initiated logout endpoint

Implements OpenID Connect RP-Initiated Logout 1.0 for IdPs (e.g. Dex) that do not natively advertise end_session_endpoint. Validates the post-logout redirect target, then 302-redirects the browser back to the SPA.

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

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

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

	localVarPath := localBasePath + "/auth/end-session"

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

	if r.postLogoutRedirectUri != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "post_logout_redirect_uri", r.postLogoutRedirectUri, "form", "")
	}
	if r.idTokenHint != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "id_token_hint", r.idTokenHint, "form", "")
	}
	if r.state != nil {
		parameterAddToHeaderOrQuery(localVarQueryParams, "state", r.state, "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{}

	// 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 localVarHTTPResponse.StatusCode >= 300 {
		newErr := &GenericOpenAPIError{
			body:  localVarBody,
			error: localVarHTTPResponse.Status,
		}
		return localVarHTTPResponse, newErr
	}

	return localVarHTTPResponse, nil
}