diff --git a/apps/api-client-go/api/openapi.yaml b/apps/api-client-go/api/openapi.yaml index 7a4f572c9..838db0321 100644 --- a/apps/api-client-go/api/openapi.yaml +++ b/apps/api-client-go/api/openapi.yaml @@ -2286,106 +2286,6 @@ paths: summary: Get preview URL for a box port tags: - box - /box/{boxIdOrName}/ports/{port}/signed-preview-url: - get: - operationId: getSignedPortPreviewUrl - parameters: - - description: Use with JWT to specify the organization ID - explode: false - in: header - name: X-BoxLite-Organization-ID - required: false - schema: - type: string - style: simple - - description: ID or name of the box - explode: false - in: path - name: boxIdOrName - required: true - schema: - type: string - style: simple - - description: Port number to get signed preview URL for - explode: false - in: path - name: port - required: true - schema: - type: integer - style: simple - - description: "Expiration time in seconds (default: 60 seconds)" - explode: true - in: query - name: expiresInSeconds - required: false - schema: - type: integer - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/SignedPortPreviewUrl" - description: Signed preview URL for the specified port - security: - - bearer: [] - - oauth2: - - openid - - profile - - email - summary: Get signed preview URL for a box port - tags: - - box - /box/{boxIdOrName}/ports/{port}/signed-preview-url/{token}/expire: - post: - operationId: expireSignedPortPreviewUrl - parameters: - - description: Use with JWT to specify the organization ID - explode: false - in: header - name: X-BoxLite-Organization-ID - required: false - schema: - type: string - style: simple - - description: ID or name of the box - explode: false - in: path - name: boxIdOrName - required: true - schema: - type: string - style: simple - - description: Port number to expire signed preview URL for - explode: false - in: path - name: port - required: true - schema: - type: integer - style: simple - - description: Token to expire signed preview URL for - explode: false - in: path - name: token - required: true - schema: - type: string - style: simple - responses: - "200": - description: Signed preview URL has been expired - security: - - bearer: [] - - oauth2: - - openid - - profile - - email - summary: Expire signed preview URL for a box port - tags: - - box /box/{boxIdOrName}/ssh-access: delete: operationId: revokeSshAccess @@ -2926,36 +2826,6 @@ paths: summary: Check if user has access to the box tags: - preview - /preview/{signedPreviewToken}/{port}/box-id: - get: - operationId: getBoxIdFromSignedPreviewUrlToken - parameters: - - description: Signed preview URL token - explode: false - in: path - name: signedPreviewToken - required: true - schema: - type: string - style: simple - - description: Port number to get box ID from signed preview URL token - explode: false - in: path - name: port - required: true - schema: - type: number - style: simple - responses: - "200": - content: - application/json: - schema: - type: string - description: Box ID from signed preview URL token - summary: Get box ID from signed preview URL token - tags: - - preview /volumes: get: operationId: listVolumes @@ -6702,7 +6572,7 @@ components: PortPreviewUrl: example: boxId: "123456" - url: "https://{port}-{boxId}.{proxyDomain}" + url: "https://{port}-{encodedBoxId}.{proxyDomain}" token: ul67qtv-jl6wb9z5o3eii-ljqt9qed6l properties: boxId: @@ -6711,7 +6581,7 @@ components: type: string url: description: Preview url - example: "https://{port}-{boxId}.{proxyDomain}" + example: "https://{port}-{encodedBoxId}.{proxyDomain}" type: string token: description: Access token @@ -6722,35 +6592,6 @@ components: - token - url type: object - SignedPortPreviewUrl: - example: - boxId: "123456" - port: 3000 - token: jl6wb9z5o3eii - url: "https://{port}-{token}.{proxyDomain}" - properties: - boxId: - description: ID of the box - example: "123456" - type: string - port: - description: Port number of the signed preview URL - example: 3000 - type: integer - token: - description: Token of the signed preview URL - example: jl6wb9z5o3eii - type: string - url: - description: Signed preview url - example: "https://{port}-{token}.{proxyDomain}" - type: string - required: - - boxId - - port - - token - - url - type: object SshAccessDto: example: id: 123e4567-e89b-12d3-a456-426614174000 diff --git a/apps/api-client-go/api_box.go b/apps/api-client-go/api_box.go index 8dae8b5f6..5558613cc 100644 --- a/apps/api-client-go/api_box.go +++ b/apps/api-client-go/api_box.go @@ -17,20 +17,19 @@ import ( "io" "net/http" "net/url" + "reflect" "strings" "time" - "reflect" ) - type BoxAPI interface { /* - CreateSshAccess Create SSH access for box + CreateSshAccess Create SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPICreateSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPICreateSshAccessRequest */ CreateSshAccess(ctx context.Context, boxIdOrName string) BoxAPICreateSshAccessRequest @@ -39,25 +38,11 @@ type BoxAPI interface { CreateSshAccessExecute(r BoxAPICreateSshAccessRequest) (*SshAccessDto, *http.Response, error) /* - ExpireSignedPortPreviewUrl Expire signed preview URL for a box port + GetBox Get box details - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to expire signed preview URL for - @param token Token to expire signed preview URL for - @return BoxAPIExpireSignedPortPreviewUrlRequest - */ - ExpireSignedPortPreviewUrl(ctx context.Context, boxIdOrName string, port int32, token string) BoxAPIExpireSignedPortPreviewUrlRequest - - // ExpireSignedPortPreviewUrlExecute executes the request - ExpireSignedPortPreviewUrlExecute(r BoxAPIExpireSignedPortPreviewUrlRequest) (*http.Response, error) - - /* - GetBox Get box details - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIGetBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIGetBoxRequest */ GetBox(ctx context.Context, boxIdOrName string) BoxAPIGetBoxRequest @@ -66,13 +51,13 @@ type BoxAPI interface { GetBoxExecute(r BoxAPIGetBoxRequest) (*Box, *http.Response, error) /* - GetBoxLogs Get box logs + GetBoxLogs Get box logs - Retrieve OTEL logs for a box within a time range + Retrieve OTEL logs for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxLogsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxLogsRequest */ GetBoxLogs(ctx context.Context, boxId string) BoxAPIGetBoxLogsRequest @@ -81,13 +66,13 @@ type BoxAPI interface { GetBoxLogsExecute(r BoxAPIGetBoxLogsRequest) (*PaginatedLogs, *http.Response, error) /* - GetBoxMetrics Get box metrics + GetBoxMetrics Get box metrics - Retrieve OTEL metrics for a box within a time range + Retrieve OTEL metrics for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxMetricsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxMetricsRequest */ GetBoxMetrics(ctx context.Context, boxId string) BoxAPIGetBoxMetricsRequest @@ -96,14 +81,14 @@ type BoxAPI interface { GetBoxMetricsExecute(r BoxAPIGetBoxMetricsRequest) (*MetricsResponse, *http.Response, error) /* - GetBoxTraceSpans Get trace spans + GetBoxTraceSpans Get trace spans - Retrieve all spans for a specific trace + Retrieve all spans for a specific trace - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @param traceId ID of the trace - @return BoxAPIGetBoxTraceSpansRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @param traceId ID of the trace + @return BoxAPIGetBoxTraceSpansRequest */ GetBoxTraceSpans(ctx context.Context, boxId string, traceId string) BoxAPIGetBoxTraceSpansRequest @@ -112,13 +97,13 @@ type BoxAPI interface { GetBoxTraceSpansExecute(r BoxAPIGetBoxTraceSpansRequest) ([]TraceSpan, *http.Response, error) /* - GetBoxTraces Get box traces + GetBoxTraces Get box traces - Retrieve OTEL traces for a box within a time range + Retrieve OTEL traces for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxTracesRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxTracesRequest */ GetBoxTraces(ctx context.Context, boxId string) BoxAPIGetBoxTracesRequest @@ -127,10 +112,10 @@ type BoxAPI interface { GetBoxTracesExecute(r BoxAPIGetBoxTracesRequest) (*PaginatedTraces, *http.Response, error) /* - GetBoxesForRunner Get boxes for the authenticated runner + GetBoxesForRunner Get boxes for the authenticated runner - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIGetBoxesForRunnerRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIGetBoxesForRunnerRequest */ GetBoxesForRunner(ctx context.Context) BoxAPIGetBoxesForRunnerRequest @@ -139,12 +124,12 @@ type BoxAPI interface { GetBoxesForRunnerExecute(r BoxAPIGetBoxesForRunnerRequest) ([]Box, *http.Response, error) /* - GetPortPreviewUrl Get preview URL for a box port + GetPortPreviewUrl Get preview URL for a box port - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to get preview URL for - @return BoxAPIGetPortPreviewUrlRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param port Port number to get preview URL for + @return BoxAPIGetPortPreviewUrlRequest */ GetPortPreviewUrl(ctx context.Context, boxIdOrName string, port float32) BoxAPIGetPortPreviewUrlRequest @@ -153,25 +138,11 @@ type BoxAPI interface { GetPortPreviewUrlExecute(r BoxAPIGetPortPreviewUrlRequest) (*PortPreviewUrl, *http.Response, error) /* - GetSignedPortPreviewUrl Get signed preview URL for a box port + GetToolboxProxyUrl Get toolbox proxy URL for a box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to get signed preview URL for - @return BoxAPIGetSignedPortPreviewUrlRequest - */ - GetSignedPortPreviewUrl(ctx context.Context, boxIdOrName string, port int32) BoxAPIGetSignedPortPreviewUrlRequest - - // GetSignedPortPreviewUrlExecute executes the request - // @return SignedPortPreviewUrl - GetSignedPortPreviewUrlExecute(r BoxAPIGetSignedPortPreviewUrlRequest) (*SignedPortPreviewUrl, *http.Response, error) - - /* - GetToolboxProxyUrl Get toolbox proxy URL for a box - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetToolboxProxyUrlRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetToolboxProxyUrlRequest */ GetToolboxProxyUrl(ctx context.Context, boxId string) BoxAPIGetToolboxProxyUrlRequest @@ -180,10 +151,10 @@ type BoxAPI interface { GetToolboxProxyUrlExecute(r BoxAPIGetToolboxProxyUrlRequest) (*ToolboxProxyUrl, *http.Response, error) /* - ListBoxes List all boxes + ListBoxes List all boxes - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIListBoxesRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIListBoxesRequest */ ListBoxes(ctx context.Context) BoxAPIListBoxesRequest @@ -192,10 +163,10 @@ type BoxAPI interface { ListBoxesExecute(r BoxAPIListBoxesRequest) ([]Box, *http.Response, error) /* - ListBoxesPaginated List all boxes paginated + ListBoxesPaginated List all boxes paginated - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIListBoxesPaginatedRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIListBoxesPaginatedRequest */ ListBoxesPaginated(ctx context.Context) BoxAPIListBoxesPaginatedRequest @@ -204,11 +175,11 @@ type BoxAPI interface { ListBoxesPaginatedExecute(r BoxAPIListBoxesPaginatedRequest) (*PaginatedBoxes, *http.Response, error) /* - RecoverBox Recover box from error state + RecoverBox Recover box from error state - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIRecoverBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIRecoverBoxRequest */ RecoverBox(ctx context.Context, boxIdOrName string) BoxAPIRecoverBoxRequest @@ -217,11 +188,11 @@ type BoxAPI interface { RecoverBoxExecute(r BoxAPIRecoverBoxRequest) (*Box, *http.Response, error) /* - ReplaceLabels Replace box labels + ReplaceLabels Replace box labels - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIReplaceLabelsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIReplaceLabelsRequest */ ReplaceLabels(ctx context.Context, boxIdOrName string) BoxAPIReplaceLabelsRequest @@ -230,11 +201,11 @@ type BoxAPI interface { ReplaceLabelsExecute(r BoxAPIReplaceLabelsRequest) (*BoxLabels, *http.Response, error) /* - ResizeBox Resize box resources + ResizeBox Resize box resources - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIResizeBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIResizeBoxRequest */ ResizeBox(ctx context.Context, boxIdOrName string) BoxAPIResizeBoxRequest @@ -243,11 +214,11 @@ type BoxAPI interface { ResizeBoxExecute(r BoxAPIResizeBoxRequest) (*Box, *http.Response, error) /* - RevokeSshAccess Revoke SSH access for box + RevokeSshAccess Revoke SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIRevokeSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIRevokeSshAccessRequest */ RevokeSshAccess(ctx context.Context, boxIdOrName string) BoxAPIRevokeSshAccessRequest @@ -256,12 +227,12 @@ type BoxAPI interface { RevokeSshAccessExecute(r BoxAPIRevokeSshAccessRequest) (*Box, *http.Response, error) /* - SetAutoDeleteInterval Set box auto-delete interval + SetAutoDeleteInterval Set box auto-delete interval - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param interval Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping) - @return BoxAPISetAutoDeleteIntervalRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param interval Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping) + @return BoxAPISetAutoDeleteIntervalRequest */ SetAutoDeleteInterval(ctx context.Context, boxIdOrName string, interval float32) BoxAPISetAutoDeleteIntervalRequest @@ -270,12 +241,12 @@ type BoxAPI interface { SetAutoDeleteIntervalExecute(r BoxAPISetAutoDeleteIntervalRequest) (*Box, *http.Response, error) /* - SetAutostopInterval Set box auto-stop interval + SetAutostopInterval Set box auto-stop interval - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param interval Auto-stop interval in minutes (0 to disable) - @return BoxAPISetAutostopIntervalRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param interval Auto-stop interval in minutes (0 to disable) + @return BoxAPISetAutostopIntervalRequest */ SetAutostopInterval(ctx context.Context, boxIdOrName string, interval float32) BoxAPISetAutostopIntervalRequest @@ -284,11 +255,11 @@ type BoxAPI interface { SetAutostopIntervalExecute(r BoxAPISetAutostopIntervalRequest) (*Box, *http.Response, error) /* - UpdateBoxState Update box state + UpdateBoxState Update box state - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIUpdateBoxStateRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIUpdateBoxStateRequest */ UpdateBoxState(ctx context.Context, boxId string) BoxAPIUpdateBoxStateRequest @@ -296,11 +267,11 @@ type BoxAPI interface { UpdateBoxStateExecute(r BoxAPIUpdateBoxStateRequest) (*http.Response, error) /* - UpdateLastActivity Update box last activity + UpdateLastActivity Update box last activity - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIUpdateLastActivityRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIUpdateLastActivityRequest */ UpdateLastActivity(ctx context.Context, boxId string) BoxAPIUpdateLastActivityRequest @@ -308,12 +279,12 @@ type BoxAPI interface { UpdateLastActivityExecute(r BoxAPIUpdateLastActivityRequest) (*http.Response, error) /* - UpdatePublicStatus Update public status + UpdatePublicStatus Update public status - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param isPublic Public status to set - @return BoxAPIUpdatePublicStatusRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param isPublic Public status to set + @return BoxAPIUpdatePublicStatusRequest */ UpdatePublicStatus(ctx context.Context, boxIdOrName string, isPublic bool) BoxAPIUpdatePublicStatusRequest @@ -322,10 +293,10 @@ type BoxAPI interface { UpdatePublicStatusExecute(r BoxAPIUpdatePublicStatusRequest) (*Box, *http.Response, error) /* - ValidateSshAccess Validate SSH access for box + ValidateSshAccess Validate SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIValidateSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIValidateSshAccessRequest */ ValidateSshAccess(ctx context.Context) BoxAPIValidateSshAccessRequest @@ -338,11 +309,11 @@ type BoxAPI interface { type BoxAPIService service type BoxAPICreateSshAccessRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string + ctx context.Context + ApiService BoxAPI + boxIdOrName string xBoxLiteOrganizationID *string - expiresInMinutes *float32 + expiresInMinutes *float32 } // Use with JWT to specify the organization ID @@ -364,26 +335,27 @@ func (r BoxAPICreateSshAccessRequest) Execute() (*SshAccessDto, *http.Response, /* CreateSshAccess Create SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPICreateSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPICreateSshAccessRequest */ func (a *BoxAPIService) CreateSshAccess(ctx context.Context, boxIdOrName string) BoxAPICreateSshAccessRequest { return BoxAPICreateSshAccessRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return SshAccessDto +// +// @return SshAccessDto func (a *BoxAPIService) CreateSshAccessExecute(r BoxAPICreateSshAccessRequest) (*SshAccessDto, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *SshAccessDto + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SshAccessDto ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.CreateSshAccess") @@ -458,120 +430,12 @@ func (a *BoxAPIService) CreateSshAccessExecute(r BoxAPICreateSshAccessRequest) ( return localVarReturnValue, localVarHTTPResponse, nil } -type BoxAPIExpireSignedPortPreviewUrlRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - port int32 - token string - xBoxLiteOrganizationID *string -} - -// Use with JWT to specify the organization ID -func (r BoxAPIExpireSignedPortPreviewUrlRequest) XBoxLiteOrganizationID(xBoxLiteOrganizationID string) BoxAPIExpireSignedPortPreviewUrlRequest { - r.xBoxLiteOrganizationID = &xBoxLiteOrganizationID - return r -} - -func (r BoxAPIExpireSignedPortPreviewUrlRequest) Execute() (*http.Response, error) { - return r.ApiService.ExpireSignedPortPreviewUrlExecute(r) -} - -/* -ExpireSignedPortPreviewUrl Expire signed preview URL for a box port - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to expire signed preview URL for - @param token Token to expire signed preview URL for - @return BoxAPIExpireSignedPortPreviewUrlRequest -*/ -func (a *BoxAPIService) ExpireSignedPortPreviewUrl(ctx context.Context, boxIdOrName string, port int32, token string) BoxAPIExpireSignedPortPreviewUrlRequest { - return BoxAPIExpireSignedPortPreviewUrlRequest{ - ApiService: a, - ctx: ctx, - boxIdOrName: boxIdOrName, - port: port, - token: token, - } -} - -// Execute executes the request -func (a *BoxAPIService) ExpireSignedPortPreviewUrlExecute(r BoxAPIExpireSignedPortPreviewUrlRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ExpireSignedPortPreviewUrl") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/box/{boxIdOrName}/ports/{port}/signed-preview-url/{token}/expire" - localVarPath = strings.Replace(localVarPath, "{"+"boxIdOrName"+"}", url.PathEscape(parameterValueToString(r.boxIdOrName, "boxIdOrName")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"port"+"}", url.PathEscape(parameterValueToString(r.port, "port")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"token"+"}", url.PathEscape(parameterValueToString(r.token, "token")), -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{} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - if r.xBoxLiteOrganizationID != nil { - parameterAddToHeaderOrQuery(localVarHeaderParams, "X-BoxLite-Organization-ID", r.xBoxLiteOrganizationID, "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 localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - type BoxAPIGetBoxRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string + ctx context.Context + ApiService BoxAPI + boxIdOrName string xBoxLiteOrganizationID *string - verbose *bool + verbose *bool } // Use with JWT to specify the organization ID @@ -593,26 +457,27 @@ func (r BoxAPIGetBoxRequest) Execute() (*Box, *http.Response, error) { /* GetBox Get box details - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIGetBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIGetBoxRequest */ func (a *BoxAPIService) GetBox(ctx context.Context, boxIdOrName string) BoxAPIGetBoxRequest { return BoxAPIGetBoxRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) GetBoxExecute(r BoxAPIGetBoxRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBox") @@ -688,16 +553,16 @@ func (a *BoxAPIService) GetBoxExecute(r BoxAPIGetBoxRequest) (*Box, *http.Respon } type BoxAPIGetBoxLogsRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string - from *time.Time - to *time.Time + ctx context.Context + ApiService BoxAPI + boxId string + from *time.Time + to *time.Time xBoxLiteOrganizationID *string - page *float32 - limit *float32 - severities *[]string - search *string + page *float32 + limit *float32 + severities *[]string + search *string } // Start of time range (ISO 8601) @@ -751,26 +616,27 @@ GetBoxLogs Get box logs Retrieve OTEL logs for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxLogsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxLogsRequest */ func (a *BoxAPIService) GetBoxLogs(ctx context.Context, boxId string) BoxAPIGetBoxLogsRequest { return BoxAPIGetBoxLogsRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return PaginatedLogs +// +// @return PaginatedLogs func (a *BoxAPIService) GetBoxLogsExecute(r BoxAPIGetBoxLogsRequest) (*PaginatedLogs, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PaginatedLogs + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PaginatedLogs ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBoxLogs") @@ -879,13 +745,13 @@ func (a *BoxAPIService) GetBoxLogsExecute(r BoxAPIGetBoxLogsRequest) (*Paginated } type BoxAPIGetBoxMetricsRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string - from *time.Time - to *time.Time + ctx context.Context + ApiService BoxAPI + boxId string + from *time.Time + to *time.Time xBoxLiteOrganizationID *string - metricNames *[]string + metricNames *[]string } // Start of time range (ISO 8601) @@ -921,26 +787,27 @@ GetBoxMetrics Get box metrics Retrieve OTEL metrics for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxMetricsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxMetricsRequest */ func (a *BoxAPIService) GetBoxMetrics(ctx context.Context, boxId string) BoxAPIGetBoxMetricsRequest { return BoxAPIGetBoxMetricsRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return MetricsResponse +// +// @return MetricsResponse func (a *BoxAPIService) GetBoxMetricsExecute(r BoxAPIGetBoxMetricsRequest) (*MetricsResponse, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *MetricsResponse + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *MetricsResponse ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBoxMetrics") @@ -1032,10 +899,10 @@ func (a *BoxAPIService) GetBoxMetricsExecute(r BoxAPIGetBoxMetricsRequest) (*Met } type BoxAPIGetBoxTraceSpansRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string - traceId string + ctx context.Context + ApiService BoxAPI + boxId string + traceId string xBoxLiteOrganizationID *string } @@ -1054,28 +921,29 @@ GetBoxTraceSpans Get trace spans Retrieve all spans for a specific trace - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @param traceId ID of the trace - @return BoxAPIGetBoxTraceSpansRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @param traceId ID of the trace + @return BoxAPIGetBoxTraceSpansRequest */ func (a *BoxAPIService) GetBoxTraceSpans(ctx context.Context, boxId string, traceId string) BoxAPIGetBoxTraceSpansRequest { return BoxAPIGetBoxTraceSpansRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, - traceId: traceId, + ctx: ctx, + boxId: boxId, + traceId: traceId, } } // Execute executes the request -// @return []TraceSpan +// +// @return []TraceSpan func (a *BoxAPIService) GetBoxTraceSpansExecute(r BoxAPIGetBoxTraceSpansRequest) ([]TraceSpan, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue []TraceSpan + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []TraceSpan ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBoxTraceSpans") @@ -1149,14 +1017,14 @@ func (a *BoxAPIService) GetBoxTraceSpansExecute(r BoxAPIGetBoxTraceSpansRequest) } type BoxAPIGetBoxTracesRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string - from *time.Time - to *time.Time + ctx context.Context + ApiService BoxAPI + boxId string + from *time.Time + to *time.Time xBoxLiteOrganizationID *string - page *float32 - limit *float32 + page *float32 + limit *float32 } // Start of time range (ISO 8601) @@ -1198,26 +1066,27 @@ GetBoxTraces Get box traces Retrieve OTEL traces for a box within a time range - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetBoxTracesRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetBoxTracesRequest */ func (a *BoxAPIService) GetBoxTraces(ctx context.Context, boxId string) BoxAPIGetBoxTracesRequest { return BoxAPIGetBoxTracesRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return PaginatedTraces +// +// @return PaginatedTraces func (a *BoxAPIService) GetBoxTracesExecute(r BoxAPIGetBoxTracesRequest) (*PaginatedTraces, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PaginatedTraces + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PaginatedTraces ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBoxTraces") @@ -1312,11 +1181,11 @@ func (a *BoxAPIService) GetBoxTracesExecute(r BoxAPIGetBoxTracesRequest) (*Pagin } type BoxAPIGetBoxesForRunnerRequest struct { - ctx context.Context - ApiService BoxAPI + ctx context.Context + ApiService BoxAPI xBoxLiteOrganizationID *string - states *string - skipReconcilingBoxes *bool + states *string + skipReconcilingBoxes *bool } // Use with JWT to specify the organization ID @@ -1344,24 +1213,25 @@ func (r BoxAPIGetBoxesForRunnerRequest) Execute() ([]Box, *http.Response, error) /* GetBoxesForRunner Get boxes for the authenticated runner - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIGetBoxesForRunnerRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIGetBoxesForRunnerRequest */ func (a *BoxAPIService) GetBoxesForRunner(ctx context.Context) BoxAPIGetBoxesForRunnerRequest { return BoxAPIGetBoxesForRunnerRequest{ ApiService: a, - ctx: ctx, + ctx: ctx, } } // Execute executes the request -// @return []Box +// +// @return []Box func (a *BoxAPIService) GetBoxesForRunnerExecute(r BoxAPIGetBoxesForRunnerRequest) ([]Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue []Box + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetBoxesForRunner") @@ -1439,10 +1309,10 @@ func (a *BoxAPIService) GetBoxesForRunnerExecute(r BoxAPIGetBoxesForRunnerReques } type BoxAPIGetPortPreviewUrlRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - port float32 + ctx context.Context + ApiService BoxAPI + boxIdOrName string + port float32 xBoxLiteOrganizationID *string } @@ -1459,28 +1329,29 @@ func (r BoxAPIGetPortPreviewUrlRequest) Execute() (*PortPreviewUrl, *http.Respon /* GetPortPreviewUrl Get preview URL for a box port - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to get preview URL for - @return BoxAPIGetPortPreviewUrlRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param port Port number to get preview URL for + @return BoxAPIGetPortPreviewUrlRequest */ func (a *BoxAPIService) GetPortPreviewUrl(ctx context.Context, boxIdOrName string, port float32) BoxAPIGetPortPreviewUrlRequest { return BoxAPIGetPortPreviewUrlRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, - port: port, + port: port, } } // Execute executes the request -// @return PortPreviewUrl +// +// @return PortPreviewUrl func (a *BoxAPIService) GetPortPreviewUrlExecute(r BoxAPIGetPortPreviewUrlRequest) (*PortPreviewUrl, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PortPreviewUrl + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PortPreviewUrl ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetPortPreviewUrl") @@ -1553,135 +1424,10 @@ func (a *BoxAPIService) GetPortPreviewUrlExecute(r BoxAPIGetPortPreviewUrlReques return localVarReturnValue, localVarHTTPResponse, nil } -type BoxAPIGetSignedPortPreviewUrlRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - port int32 - xBoxLiteOrganizationID *string - expiresInSeconds *int32 -} - -// Use with JWT to specify the organization ID -func (r BoxAPIGetSignedPortPreviewUrlRequest) XBoxLiteOrganizationID(xBoxLiteOrganizationID string) BoxAPIGetSignedPortPreviewUrlRequest { - r.xBoxLiteOrganizationID = &xBoxLiteOrganizationID - return r -} - -// Expiration time in seconds (default: 60 seconds) -func (r BoxAPIGetSignedPortPreviewUrlRequest) ExpiresInSeconds(expiresInSeconds int32) BoxAPIGetSignedPortPreviewUrlRequest { - r.expiresInSeconds = &expiresInSeconds - return r -} - -func (r BoxAPIGetSignedPortPreviewUrlRequest) Execute() (*SignedPortPreviewUrl, *http.Response, error) { - return r.ApiService.GetSignedPortPreviewUrlExecute(r) -} - -/* -GetSignedPortPreviewUrl Get signed preview URL for a box port - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param port Port number to get signed preview URL for - @return BoxAPIGetSignedPortPreviewUrlRequest -*/ -func (a *BoxAPIService) GetSignedPortPreviewUrl(ctx context.Context, boxIdOrName string, port int32) BoxAPIGetSignedPortPreviewUrlRequest { - return BoxAPIGetSignedPortPreviewUrlRequest{ - ApiService: a, - ctx: ctx, - boxIdOrName: boxIdOrName, - port: port, - } -} - -// Execute executes the request -// @return SignedPortPreviewUrl -func (a *BoxAPIService) GetSignedPortPreviewUrlExecute(r BoxAPIGetSignedPortPreviewUrlRequest) (*SignedPortPreviewUrl, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *SignedPortPreviewUrl - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetSignedPortPreviewUrl") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/box/{boxIdOrName}/ports/{port}/signed-preview-url" - localVarPath = strings.Replace(localVarPath, "{"+"boxIdOrName"+"}", url.PathEscape(parameterValueToString(r.boxIdOrName, "boxIdOrName")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"port"+"}", url.PathEscape(parameterValueToString(r.port, "port")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.expiresInSeconds != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "expiresInSeconds", r.expiresInSeconds, "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 - } - if r.xBoxLiteOrganizationID != nil { - parameterAddToHeaderOrQuery(localVarHeaderParams, "X-BoxLite-Organization-ID", r.xBoxLiteOrganizationID, "simple", "") - } - 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, - } - 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 BoxAPIGetToolboxProxyUrlRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string + ctx context.Context + ApiService BoxAPI + boxId string xBoxLiteOrganizationID *string } @@ -1698,26 +1444,27 @@ func (r BoxAPIGetToolboxProxyUrlRequest) Execute() (*ToolboxProxyUrl, *http.Resp /* GetToolboxProxyUrl Get toolbox proxy URL for a box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIGetToolboxProxyUrlRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIGetToolboxProxyUrlRequest */ func (a *BoxAPIService) GetToolboxProxyUrl(ctx context.Context, boxId string) BoxAPIGetToolboxProxyUrlRequest { return BoxAPIGetToolboxProxyUrlRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return ToolboxProxyUrl +// +// @return ToolboxProxyUrl func (a *BoxAPIService) GetToolboxProxyUrlExecute(r BoxAPIGetToolboxProxyUrlRequest) (*ToolboxProxyUrl, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ToolboxProxyUrl + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ToolboxProxyUrl ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.GetToolboxProxyUrl") @@ -1790,12 +1537,12 @@ func (a *BoxAPIService) GetToolboxProxyUrlExecute(r BoxAPIGetToolboxProxyUrlRequ } type BoxAPIListBoxesRequest struct { - ctx context.Context - ApiService BoxAPI + ctx context.Context + ApiService BoxAPI xBoxLiteOrganizationID *string - verbose *bool - labels *string - includeErroredDeleted *bool + verbose *bool + labels *string + includeErroredDeleted *bool } // Use with JWT to specify the organization ID @@ -1829,24 +1576,25 @@ func (r BoxAPIListBoxesRequest) Execute() ([]Box, *http.Response, error) { /* ListBoxes List all boxes - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIListBoxesRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIListBoxesRequest */ func (a *BoxAPIService) ListBoxes(ctx context.Context) BoxAPIListBoxesRequest { return BoxAPIListBoxesRequest{ ApiService: a, - ctx: ctx, + ctx: ctx, } } // Execute executes the request -// @return []Box +// +// @return []Box func (a *BoxAPIService) ListBoxesExecute(r BoxAPIListBoxesRequest) ([]Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue []Box + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ListBoxes") @@ -1927,27 +1675,27 @@ func (a *BoxAPIService) ListBoxesExecute(r BoxAPIListBoxesRequest) ([]Box, *http } type BoxAPIListBoxesPaginatedRequest struct { - ctx context.Context - ApiService BoxAPI + ctx context.Context + ApiService BoxAPI xBoxLiteOrganizationID *string - page *float32 - limit *float32 - id *string - name *string - labels *string - includeErroredDeleted *bool - states *[]string - regions *[]string - minCpu *float32 - maxCpu *float32 - minMemoryGiB *float32 - maxMemoryGiB *float32 - minDiskGiB *float32 - maxDiskGiB *float32 - lastEventAfter *time.Time - lastEventBefore *time.Time - sort *string - order *string + page *float32 + limit *float32 + id *string + name *string + labels *string + includeErroredDeleted *bool + states *[]string + regions *[]string + minCpu *float32 + maxCpu *float32 + minMemoryGiB *float32 + maxMemoryGiB *float32 + minDiskGiB *float32 + maxDiskGiB *float32 + lastEventAfter *time.Time + lastEventBefore *time.Time + sort *string + order *string } // Use with JWT to specify the organization ID @@ -2071,24 +1819,25 @@ func (r BoxAPIListBoxesPaginatedRequest) Execute() (*PaginatedBoxes, *http.Respo /* ListBoxesPaginated List all boxes paginated - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIListBoxesPaginatedRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIListBoxesPaginatedRequest */ func (a *BoxAPIService) ListBoxesPaginated(ctx context.Context) BoxAPIListBoxesPaginatedRequest { return BoxAPIListBoxesPaginatedRequest{ ApiService: a, - ctx: ctx, + ctx: ctx, } } // Execute executes the request -// @return PaginatedBoxes +// +// @return PaginatedBoxes func (a *BoxAPIService) ListBoxesPaginatedExecute(r BoxAPIListBoxesPaginatedRequest) (*PaginatedBoxes, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *PaginatedBoxes + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *PaginatedBoxes ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ListBoxesPaginated") @@ -2250,9 +1999,9 @@ func (a *BoxAPIService) ListBoxesPaginatedExecute(r BoxAPIListBoxesPaginatedRequ } type BoxAPIRecoverBoxRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string + ctx context.Context + ApiService BoxAPI + boxIdOrName string xBoxLiteOrganizationID *string } @@ -2269,26 +2018,27 @@ func (r BoxAPIRecoverBoxRequest) Execute() (*Box, *http.Response, error) { /* RecoverBox Recover box from error state - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIRecoverBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIRecoverBoxRequest */ func (a *BoxAPIService) RecoverBox(ctx context.Context, boxIdOrName string) BoxAPIRecoverBoxRequest { return BoxAPIRecoverBoxRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) RecoverBoxExecute(r BoxAPIRecoverBoxRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.RecoverBox") @@ -2361,10 +2111,10 @@ func (a *BoxAPIService) RecoverBoxExecute(r BoxAPIRecoverBoxRequest) (*Box, *htt } type BoxAPIReplaceLabelsRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - boxLabels *BoxLabels + ctx context.Context + ApiService BoxAPI + boxIdOrName string + boxLabels *BoxLabels xBoxLiteOrganizationID *string } @@ -2386,26 +2136,27 @@ func (r BoxAPIReplaceLabelsRequest) Execute() (*BoxLabels, *http.Response, error /* ReplaceLabels Replace box labels - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIReplaceLabelsRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIReplaceLabelsRequest */ func (a *BoxAPIService) ReplaceLabels(ctx context.Context, boxIdOrName string) BoxAPIReplaceLabelsRequest { return BoxAPIReplaceLabelsRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return BoxLabels +// +// @return BoxLabels func (a *BoxAPIService) ReplaceLabelsExecute(r BoxAPIReplaceLabelsRequest) (*BoxLabels, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *BoxLabels + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *BoxLabels ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ReplaceLabels") @@ -2483,10 +2234,10 @@ func (a *BoxAPIService) ReplaceLabelsExecute(r BoxAPIReplaceLabelsRequest) (*Box } type BoxAPIResizeBoxRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - resizeBox *ResizeBox + ctx context.Context + ApiService BoxAPI + boxIdOrName string + resizeBox *ResizeBox xBoxLiteOrganizationID *string } @@ -2508,26 +2259,27 @@ func (r BoxAPIResizeBoxRequest) Execute() (*Box, *http.Response, error) { /* ResizeBox Resize box resources - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIResizeBoxRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIResizeBoxRequest */ func (a *BoxAPIService) ResizeBox(ctx context.Context, boxIdOrName string) BoxAPIResizeBoxRequest { return BoxAPIResizeBoxRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) ResizeBoxExecute(r BoxAPIResizeBoxRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ResizeBox") @@ -2605,11 +2357,11 @@ func (a *BoxAPIService) ResizeBoxExecute(r BoxAPIResizeBoxRequest) (*Box, *http. } type BoxAPIRevokeSshAccessRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string + ctx context.Context + ApiService BoxAPI + boxIdOrName string xBoxLiteOrganizationID *string - token *string + token *string } // Use with JWT to specify the organization ID @@ -2631,26 +2383,27 @@ func (r BoxAPIRevokeSshAccessRequest) Execute() (*Box, *http.Response, error) { /* RevokeSshAccess Revoke SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @return BoxAPIRevokeSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @return BoxAPIRevokeSshAccessRequest */ func (a *BoxAPIService) RevokeSshAccess(ctx context.Context, boxIdOrName string) BoxAPIRevokeSshAccessRequest { return BoxAPIRevokeSshAccessRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) RevokeSshAccessExecute(r BoxAPIRevokeSshAccessRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.RevokeSshAccess") @@ -2726,10 +2479,10 @@ func (a *BoxAPIService) RevokeSshAccessExecute(r BoxAPIRevokeSshAccessRequest) ( } type BoxAPISetAutoDeleteIntervalRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - interval float32 + ctx context.Context + ApiService BoxAPI + boxIdOrName string + interval float32 xBoxLiteOrganizationID *string } @@ -2746,28 +2499,29 @@ func (r BoxAPISetAutoDeleteIntervalRequest) Execute() (*Box, *http.Response, err /* SetAutoDeleteInterval Set box auto-delete interval - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param interval Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping) - @return BoxAPISetAutoDeleteIntervalRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param interval Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping) + @return BoxAPISetAutoDeleteIntervalRequest */ func (a *BoxAPIService) SetAutoDeleteInterval(ctx context.Context, boxIdOrName string, interval float32) BoxAPISetAutoDeleteIntervalRequest { return BoxAPISetAutoDeleteIntervalRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, - interval: interval, + interval: interval, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) SetAutoDeleteIntervalExecute(r BoxAPISetAutoDeleteIntervalRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.SetAutoDeleteInterval") @@ -2841,10 +2595,10 @@ func (a *BoxAPIService) SetAutoDeleteIntervalExecute(r BoxAPISetAutoDeleteInterv } type BoxAPISetAutostopIntervalRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - interval float32 + ctx context.Context + ApiService BoxAPI + boxIdOrName string + interval float32 xBoxLiteOrganizationID *string } @@ -2861,28 +2615,29 @@ func (r BoxAPISetAutostopIntervalRequest) Execute() (*Box, *http.Response, error /* SetAutostopInterval Set box auto-stop interval - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param interval Auto-stop interval in minutes (0 to disable) - @return BoxAPISetAutostopIntervalRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param interval Auto-stop interval in minutes (0 to disable) + @return BoxAPISetAutostopIntervalRequest */ func (a *BoxAPIService) SetAutostopInterval(ctx context.Context, boxIdOrName string, interval float32) BoxAPISetAutostopIntervalRequest { return BoxAPISetAutostopIntervalRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, - interval: interval, + interval: interval, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) SetAutostopIntervalExecute(r BoxAPISetAutostopIntervalRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.SetAutostopInterval") @@ -2956,10 +2711,10 @@ func (a *BoxAPIService) SetAutostopIntervalExecute(r BoxAPISetAutostopIntervalRe } type BoxAPIUpdateBoxStateRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string - updateBoxStateDto *UpdateBoxStateDto + ctx context.Context + ApiService BoxAPI + boxId string + updateBoxStateDto *UpdateBoxStateDto xBoxLiteOrganizationID *string } @@ -2981,24 +2736,24 @@ func (r BoxAPIUpdateBoxStateRequest) Execute() (*http.Response, error) { /* UpdateBoxState Update box state - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIUpdateBoxStateRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIUpdateBoxStateRequest */ func (a *BoxAPIService) UpdateBoxState(ctx context.Context, boxId string) BoxAPIUpdateBoxStateRequest { return BoxAPIUpdateBoxStateRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request func (a *BoxAPIService) UpdateBoxStateExecute(r BoxAPIUpdateBoxStateRequest) (*http.Response, error) { var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.UpdateBoxState") @@ -3067,9 +2822,9 @@ func (a *BoxAPIService) UpdateBoxStateExecute(r BoxAPIUpdateBoxStateRequest) (*h } type BoxAPIUpdateLastActivityRequest struct { - ctx context.Context - ApiService BoxAPI - boxId string + ctx context.Context + ApiService BoxAPI + boxId string xBoxLiteOrganizationID *string } @@ -3086,24 +2841,24 @@ func (r BoxAPIUpdateLastActivityRequest) Execute() (*http.Response, error) { /* UpdateLastActivity Update box last activity - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return BoxAPIUpdateLastActivityRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return BoxAPIUpdateLastActivityRequest */ func (a *BoxAPIService) UpdateLastActivity(ctx context.Context, boxId string) BoxAPIUpdateLastActivityRequest { return BoxAPIUpdateLastActivityRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request func (a *BoxAPIService) UpdateLastActivityExecute(r BoxAPIUpdateLastActivityRequest) (*http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.UpdateLastActivity") @@ -3167,10 +2922,10 @@ func (a *BoxAPIService) UpdateLastActivityExecute(r BoxAPIUpdateLastActivityRequ } type BoxAPIUpdatePublicStatusRequest struct { - ctx context.Context - ApiService BoxAPI - boxIdOrName string - isPublic bool + ctx context.Context + ApiService BoxAPI + boxIdOrName string + isPublic bool xBoxLiteOrganizationID *string } @@ -3187,28 +2942,29 @@ func (r BoxAPIUpdatePublicStatusRequest) Execute() (*Box, *http.Response, error) /* UpdatePublicStatus Update public status - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxIdOrName ID or name of the box - @param isPublic Public status to set - @return BoxAPIUpdatePublicStatusRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxIdOrName ID or name of the box + @param isPublic Public status to set + @return BoxAPIUpdatePublicStatusRequest */ func (a *BoxAPIService) UpdatePublicStatus(ctx context.Context, boxIdOrName string, isPublic bool) BoxAPIUpdatePublicStatusRequest { return BoxAPIUpdatePublicStatusRequest{ - ApiService: a, - ctx: ctx, + ApiService: a, + ctx: ctx, boxIdOrName: boxIdOrName, - isPublic: isPublic, + isPublic: isPublic, } } // Execute executes the request -// @return Box +// +// @return Box func (a *BoxAPIService) UpdatePublicStatusExecute(r BoxAPIUpdatePublicStatusRequest) (*Box, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *Box + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *Box ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.UpdatePublicStatus") @@ -3282,9 +3038,9 @@ func (a *BoxAPIService) UpdatePublicStatusExecute(r BoxAPIUpdatePublicStatusRequ } type BoxAPIValidateSshAccessRequest struct { - ctx context.Context - ApiService BoxAPI - token *string + ctx context.Context + ApiService BoxAPI + token *string xBoxLiteOrganizationID *string } @@ -3307,24 +3063,25 @@ func (r BoxAPIValidateSshAccessRequest) Execute() (*SshAccessValidationDto, *htt /* ValidateSshAccess Validate SSH access for box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return BoxAPIValidateSshAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return BoxAPIValidateSshAccessRequest */ func (a *BoxAPIService) ValidateSshAccess(ctx context.Context) BoxAPIValidateSshAccessRequest { return BoxAPIValidateSshAccessRequest{ ApiService: a, - ctx: ctx, + ctx: ctx, } } // Execute executes the request -// @return SshAccessValidationDto +// +// @return SshAccessValidationDto func (a *BoxAPIService) ValidateSshAccessExecute(r BoxAPIValidateSshAccessRequest) (*SshAccessValidationDto, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *SshAccessValidationDto + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *SshAccessValidationDto ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BoxAPIService.ValidateSshAccess") diff --git a/apps/api-client-go/api_preview.go b/apps/api-client-go/api_preview.go index 83f265fc4..18ea48642 100644 --- a/apps/api-client-go/api_preview.go +++ b/apps/api-client-go/api_preview.go @@ -20,29 +20,14 @@ import ( "strings" ) - type PreviewAPI interface { /* - GetBoxIdFromSignedPreviewUrlToken Get box ID from signed preview URL token - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param signedPreviewToken Signed preview URL token - @param port Port number to get box ID from signed preview URL token - @return PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest - */ - GetBoxIdFromSignedPreviewUrlToken(ctx context.Context, signedPreviewToken string, port float32) PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest - - // GetBoxIdFromSignedPreviewUrlTokenExecute executes the request - // @return string - GetBoxIdFromSignedPreviewUrlTokenExecute(r PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest) (string, *http.Response, error) - - /* - HasBoxAccess Check if user has access to the box + HasBoxAccess Check if user has access to the box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId - @return PreviewAPIHasBoxAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId + @return PreviewAPIHasBoxAccessRequest */ HasBoxAccess(ctx context.Context, boxId string) PreviewAPIHasBoxAccessRequest @@ -51,11 +36,11 @@ type PreviewAPI interface { HasBoxAccessExecute(r PreviewAPIHasBoxAccessRequest) (bool, *http.Response, error) /* - IsBoxPublic Check if box is public + IsBoxPublic Check if box is public - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return PreviewAPIIsBoxPublicRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return PreviewAPIIsBoxPublicRequest */ IsBoxPublic(ctx context.Context, boxId string) PreviewAPIIsBoxPublicRequest @@ -64,12 +49,12 @@ type PreviewAPI interface { IsBoxPublicExecute(r PreviewAPIIsBoxPublicRequest) (bool, *http.Response, error) /* - IsValidAuthToken Check if box auth token is valid + IsValidAuthToken Check if box auth token is valid - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @param authToken Auth token of the box - @return PreviewAPIIsValidAuthTokenRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @param authToken Auth token of the box + @return PreviewAPIIsValidAuthTokenRequest */ IsValidAuthToken(ctx context.Context, boxId string, authToken string) PreviewAPIIsValidAuthTokenRequest @@ -81,115 +66,10 @@ type PreviewAPI interface { // PreviewAPIService PreviewAPI service type PreviewAPIService service -type PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest struct { - ctx context.Context - ApiService PreviewAPI - signedPreviewToken string - port float32 -} - -func (r PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest) Execute() (string, *http.Response, error) { - return r.ApiService.GetBoxIdFromSignedPreviewUrlTokenExecute(r) -} - -/* -GetBoxIdFromSignedPreviewUrlToken Get box ID from signed preview URL token - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param signedPreviewToken Signed preview URL token - @param port Port number to get box ID from signed preview URL token - @return PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest -*/ -func (a *PreviewAPIService) GetBoxIdFromSignedPreviewUrlToken(ctx context.Context, signedPreviewToken string, port float32) PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest { - return PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest{ - ApiService: a, - ctx: ctx, - signedPreviewToken: signedPreviewToken, - port: port, - } -} - -// Execute executes the request -// @return string -func (a *PreviewAPIService) GetBoxIdFromSignedPreviewUrlTokenExecute(r PreviewAPIGetBoxIdFromSignedPreviewUrlTokenRequest) (string, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue string - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PreviewAPIService.GetBoxIdFromSignedPreviewUrlToken") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/preview/{signedPreviewToken}/{port}/box-id" - localVarPath = strings.Replace(localVarPath, "{"+"signedPreviewToken"+"}", url.PathEscape(parameterValueToString(r.signedPreviewToken, "signedPreviewToken")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"port"+"}", url.PathEscape(parameterValueToString(r.port, "port")), -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, - } - 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 PreviewAPIHasBoxAccessRequest struct { - ctx context.Context + ctx context.Context ApiService PreviewAPI - boxId string + boxId string } func (r PreviewAPIHasBoxAccessRequest) Execute() (bool, *http.Response, error) { @@ -199,26 +79,27 @@ func (r PreviewAPIHasBoxAccessRequest) Execute() (bool, *http.Response, error) { /* HasBoxAccess Check if user has access to the box - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId - @return PreviewAPIHasBoxAccessRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId + @return PreviewAPIHasBoxAccessRequest */ func (a *PreviewAPIService) HasBoxAccess(ctx context.Context, boxId string) PreviewAPIHasBoxAccessRequest { return PreviewAPIHasBoxAccessRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return bool +// +// @return bool func (a *PreviewAPIService) HasBoxAccessExecute(r PreviewAPIHasBoxAccessRequest) (bool, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue bool + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue bool ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PreviewAPIService.HasBoxAccess") @@ -288,9 +169,9 @@ func (a *PreviewAPIService) HasBoxAccessExecute(r PreviewAPIHasBoxAccessRequest) } type PreviewAPIIsBoxPublicRequest struct { - ctx context.Context + ctx context.Context ApiService PreviewAPI - boxId string + boxId string } func (r PreviewAPIIsBoxPublicRequest) Execute() (bool, *http.Response, error) { @@ -300,26 +181,27 @@ func (r PreviewAPIIsBoxPublicRequest) Execute() (bool, *http.Response, error) { /* IsBoxPublic Check if box is public - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @return PreviewAPIIsBoxPublicRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @return PreviewAPIIsBoxPublicRequest */ func (a *PreviewAPIService) IsBoxPublic(ctx context.Context, boxId string) PreviewAPIIsBoxPublicRequest { return PreviewAPIIsBoxPublicRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, + ctx: ctx, + boxId: boxId, } } // Execute executes the request -// @return bool +// +// @return bool func (a *PreviewAPIService) IsBoxPublicExecute(r PreviewAPIIsBoxPublicRequest) (bool, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue bool + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue bool ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PreviewAPIService.IsBoxPublic") @@ -389,10 +271,10 @@ func (a *PreviewAPIService) IsBoxPublicExecute(r PreviewAPIIsBoxPublicRequest) ( } type PreviewAPIIsValidAuthTokenRequest struct { - ctx context.Context + ctx context.Context ApiService PreviewAPI - boxId string - authToken string + boxId string + authToken string } func (r PreviewAPIIsValidAuthTokenRequest) Execute() (bool, *http.Response, error) { @@ -402,28 +284,29 @@ func (r PreviewAPIIsValidAuthTokenRequest) Execute() (bool, *http.Response, erro /* IsValidAuthToken Check if box auth token is valid - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param boxId ID of the box - @param authToken Auth token of the box - @return PreviewAPIIsValidAuthTokenRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param boxId ID of the box + @param authToken Auth token of the box + @return PreviewAPIIsValidAuthTokenRequest */ func (a *PreviewAPIService) IsValidAuthToken(ctx context.Context, boxId string, authToken string) PreviewAPIIsValidAuthTokenRequest { return PreviewAPIIsValidAuthTokenRequest{ ApiService: a, - ctx: ctx, - boxId: boxId, - authToken: authToken, + ctx: ctx, + boxId: boxId, + authToken: authToken, } } // Execute executes the request -// @return bool +// +// @return bool func (a *PreviewAPIService) IsValidAuthTokenExecute(r PreviewAPIIsValidAuthTokenRequest) (bool, *http.Response, error) { var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue bool + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue bool ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PreviewAPIService.IsValidAuthToken") diff --git a/apps/api-client-go/model_signed_port_preview_url.go b/apps/api-client-go/model_signed_port_preview_url.go deleted file mode 100644 index 793f1d4c4..000000000 --- a/apps/api-client-go/model_signed_port_preview_url.go +++ /dev/null @@ -1,260 +0,0 @@ -/* -BoxLite - -BoxLite AI platform API Docs - -API version: 1.0 -Contact: support@boxlite.com -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package apiclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the SignedPortPreviewUrl type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &SignedPortPreviewUrl{} - -// SignedPortPreviewUrl struct for SignedPortPreviewUrl -type SignedPortPreviewUrl struct { - // ID of the box - BoxId string `json:"boxId"` - // Port number of the signed preview URL - Port int32 `json:"port"` - // Token of the signed preview URL - Token string `json:"token"` - // Signed preview url - Url string `json:"url"` - AdditionalProperties map[string]interface{} -} - -type _SignedPortPreviewUrl SignedPortPreviewUrl - -// NewSignedPortPreviewUrl instantiates a new SignedPortPreviewUrl object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewSignedPortPreviewUrl(boxId string, port int32, token string, url string) *SignedPortPreviewUrl { - this := SignedPortPreviewUrl{} - this.BoxId = boxId - this.Port = port - this.Token = token - this.Url = url - return &this -} - -// NewSignedPortPreviewUrlWithDefaults instantiates a new SignedPortPreviewUrl object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewSignedPortPreviewUrlWithDefaults() *SignedPortPreviewUrl { - this := SignedPortPreviewUrl{} - return &this -} - -// GetBoxId returns the BoxId field value -func (o *SignedPortPreviewUrl) GetBoxId() string { - if o == nil { - var ret string - return ret - } - - return o.BoxId -} - -// GetBoxIdOk returns a tuple with the BoxId field value -// and a boolean to check if the value has been set. -func (o *SignedPortPreviewUrl) GetBoxIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.BoxId, true -} - -// SetBoxId sets field value -func (o *SignedPortPreviewUrl) SetBoxId(v string) { - o.BoxId = v -} - -// GetPort returns the Port field value -func (o *SignedPortPreviewUrl) GetPort() int32 { - if o == nil { - var ret int32 - return ret - } - - return o.Port -} - -// GetPortOk returns a tuple with the Port field value -// and a boolean to check if the value has been set. -func (o *SignedPortPreviewUrl) GetPortOk() (*int32, bool) { - if o == nil { - return nil, false - } - return &o.Port, true -} - -// SetPort sets field value -func (o *SignedPortPreviewUrl) SetPort(v int32) { - o.Port = v -} - -// GetToken returns the Token field value -func (o *SignedPortPreviewUrl) GetToken() string { - if o == nil { - var ret string - return ret - } - - return o.Token -} - -// GetTokenOk returns a tuple with the Token field value -// and a boolean to check if the value has been set. -func (o *SignedPortPreviewUrl) GetTokenOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Token, true -} - -// SetToken sets field value -func (o *SignedPortPreviewUrl) SetToken(v string) { - o.Token = v -} - -// GetUrl returns the Url field value -func (o *SignedPortPreviewUrl) GetUrl() string { - if o == nil { - var ret string - return ret - } - - return o.Url -} - -// GetUrlOk returns a tuple with the Url field value -// and a boolean to check if the value has been set. -func (o *SignedPortPreviewUrl) GetUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Url, true -} - -// SetUrl sets field value -func (o *SignedPortPreviewUrl) SetUrl(v string) { - o.Url = v -} - -func (o SignedPortPreviewUrl) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o SignedPortPreviewUrl) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["boxId"] = o.BoxId - toSerialize["port"] = o.Port - toSerialize["token"] = o.Token - toSerialize["url"] = o.Url - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *SignedPortPreviewUrl) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "boxId", - "port", - "token", - "url", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varSignedPortPreviewUrl := _SignedPortPreviewUrl{} - - err = json.Unmarshal(data, &varSignedPortPreviewUrl) - - if err != nil { - return err - } - - *o = SignedPortPreviewUrl(varSignedPortPreviewUrl) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "boxId") - delete(additionalProperties, "port") - delete(additionalProperties, "token") - delete(additionalProperties, "url") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableSignedPortPreviewUrl struct { - value *SignedPortPreviewUrl - isSet bool -} - -func (v NullableSignedPortPreviewUrl) Get() *SignedPortPreviewUrl { - return v.value -} - -func (v *NullableSignedPortPreviewUrl) Set(val *SignedPortPreviewUrl) { - v.value = val - v.isSet = true -} - -func (v NullableSignedPortPreviewUrl) IsSet() bool { - return v.isSet -} - -func (v *NullableSignedPortPreviewUrl) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableSignedPortPreviewUrl(val *SignedPortPreviewUrl) *NullableSignedPortPreviewUrl { - return &NullableSignedPortPreviewUrl{value: val, isSet: true} -} - -func (v NullableSignedPortPreviewUrl) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableSignedPortPreviewUrl) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/apps/api/src/box/controllers/box.controller.ts b/apps/api/src/box/controllers/box.controller.ts index c70d76627..9dc7f15df 100644 --- a/apps/api/src/box/controllers/box.controller.ts +++ b/apps/api/src/box/controllers/box.controller.ts @@ -48,7 +48,7 @@ import { OrganizationAuthContext } from '../../common/interfaces/auth-context.in import { RequiredOrganizationResourcePermissions } from '../../organization/decorators/required-organization-resource-permissions.decorator' import { OrganizationResourcePermission } from '../../organization/enums/organization-resource-permission.enum' import { OrganizationResourceActionGuard } from '../../organization/guards/organization-resource-action.guard' -import { PortPreviewUrlDto, SignedPortPreviewUrlDto } from '../dto/port-preview-url.dto' +import { PortPreviewUrlDto } from '../dto/port-preview-url.dto' import { BadRequestError } from '../../exceptions/bad-request.exception' import { BoxStateUpdatedEvent } from '../events/box-state-updated.event' import { Audit, TypedRequest } from '../../audit/decorators/audit.decorator' @@ -656,76 +656,6 @@ export class BoxController { return this.boxService.getPortPreviewUrl(boxIdOrName, authContext.organizationId, port) } - @Get(':boxIdOrName/ports/:port/signed-preview-url') - @ApiOperation({ - summary: 'Get signed preview URL for a box port', - operationId: 'getSignedPortPreviewUrl', - }) - @ApiParam({ - name: 'boxIdOrName', - description: 'ID or name of the box', - type: 'string', - }) - @ApiParam({ - name: 'port', - description: 'Port number to get signed preview URL for', - type: 'integer', - }) - @ApiQuery({ - name: 'expiresInSeconds', - required: false, - type: 'integer', - description: 'Expiration time in seconds (default: 60 seconds)', - }) - @ApiResponse({ - status: 200, - description: 'Signed preview URL for the specified port', - type: SignedPortPreviewUrlDto, - }) - @UseGuards(BoxAccessGuard) - async getSignedPortPreviewUrl( - @AuthContext() authContext: OrganizationAuthContext, - @Param('boxIdOrName') boxIdOrName: string, - @Param('port') port: number, - @Query('expiresInSeconds') expiresInSeconds?: number, - ): Promise { - return this.boxService.getSignedPortPreviewUrl(boxIdOrName, authContext.organizationId, port, expiresInSeconds) - } - - @Post(':boxIdOrName/ports/:port/signed-preview-url/:token/expire') - @ApiOperation({ - summary: 'Expire signed preview URL for a box port', - operationId: 'expireSignedPortPreviewUrl', - }) - @ApiParam({ - name: 'boxIdOrName', - description: 'ID or name of the box', - type: 'string', - }) - @ApiParam({ - name: 'port', - description: 'Port number to expire signed preview URL for', - type: 'integer', - }) - @ApiParam({ - name: 'token', - description: 'Token to expire signed preview URL for', - type: 'string', - }) - @ApiResponse({ - status: 200, - description: 'Signed preview URL has been expired', - }) - @UseGuards(BoxAccessGuard) - async expireSignedPortPreviewUrl( - @AuthContext() authContext: OrganizationAuthContext, - @Param('boxIdOrName') boxIdOrName: string, - @Param('port') port: number, - @Param('token') token: string, - ): Promise { - await this.boxService.expireSignedPreviewUrlToken(boxIdOrName, authContext.organizationId, token, port) - } - @Post(':boxIdOrName/ssh-access') @HttpCode(200) @ApiOperation({ diff --git a/apps/api/src/box/controllers/preview.controller.ts b/apps/api/src/box/controllers/preview.controller.ts index 0c2828c7e..394511253 100644 --- a/apps/api/src/box/controllers/preview.controller.ts +++ b/apps/api/src/box/controllers/preview.controller.ts @@ -149,30 +149,4 @@ export class PreviewController { return true } - @Get(':signedPreviewToken/:port/box-id') - @ApiOperation({ - summary: 'Get box ID from signed preview URL token', - operationId: 'getBoxIdFromSignedPreviewUrlToken', - }) - @ApiParam({ - name: 'signedPreviewToken', - description: 'Signed preview URL token', - type: 'string', - }) - @ApiParam({ - name: 'port', - description: 'Port number to get box ID from signed preview URL token', - type: 'number', - }) - @ApiResponse({ - status: 200, - description: 'Box ID from signed preview URL token', - type: String, - }) - async getBoxIdFromSignedPreviewUrlToken( - @Param('signedPreviewToken') signedPreviewToken: string, - @Param('port') port: number, - ): Promise { - return this.boxService.getBoxIdFromSignedPreviewUrlToken(signedPreviewToken, port) - } } diff --git a/apps/api/src/box/dto/port-preview-url.dto.ts b/apps/api/src/box/dto/port-preview-url.dto.ts index 727c373c5..81c6de3d4 100644 --- a/apps/api/src/box/dto/port-preview-url.dto.ts +++ b/apps/api/src/box/dto/port-preview-url.dto.ts @@ -5,7 +5,7 @@ */ import { ApiProperty, ApiSchema } from '@nestjs/swagger' -import { IsNumber, IsString } from 'class-validator' +import { IsString } from 'class-validator' @ApiSchema({ name: 'PortPreviewUrl' }) export class PortPreviewUrlDto { @@ -18,7 +18,7 @@ export class PortPreviewUrlDto { @ApiProperty({ description: 'Preview url', - example: 'https://{port}-{boxId}.{proxyDomain}', + example: 'https://{port}-{encodedBoxId}.{proxyDomain}', }) @IsString() url: string @@ -30,35 +30,3 @@ export class PortPreviewUrlDto { @IsString() token: string } - -@ApiSchema({ name: 'SignedPortPreviewUrl' }) -export class SignedPortPreviewUrlDto { - @ApiProperty({ - description: 'ID of the box', - example: '123456', - }) - @IsString() - boxId: string - - @ApiProperty({ - description: 'Port number of the signed preview URL', - example: 3000, - type: 'integer', - }) - @IsNumber() - port: number - - @ApiProperty({ - description: 'Token of the signed preview URL', - example: 'jl6wb9z5o3eii', - }) - @IsString() - token: string - - @ApiProperty({ - description: 'Signed preview url', - example: 'https://{port}-{token}.{proxyDomain}', - }) - @IsString() - url: string -} diff --git a/apps/api/src/box/services/box.service.spec.ts b/apps/api/src/box/services/box.service.spec.ts index 36c029ee9..35d57bbb4 100644 --- a/apps/api/src/box/services/box.service.spec.ts +++ b/apps/api/src/box/services/box.service.spec.ts @@ -57,6 +57,54 @@ const stoppedBox = { pending: false, } +function makePreviewUrlService() { + const configService = { + getOrThrow: jest.fn((key: string) => { + if (key === 'proxy.domain') return 'proxy.example.test' + if (key === 'proxy.protocol') return 'https' + throw new Error(`unexpected config key ${key}`) + }), + } as any + const regionService = { findOne: jest.fn().mockResolvedValue(null) } as any + const noop = {} as any + const service = new BoxService( + noop, // boxRepository + noop, // runnerRepository + noop, // sshAccessRepository + noop, // runnerService + noop, // volumeService + configService, // configService + noop, // warmPoolService + noop, // eventEmitter + noop, // organizationService + noop, // runnerAdapterFactory + noop, // redisLockProvider + noop, // redis + regionService, // regionService + noop, // boxLookupCacheInvalidationService + noop, // boxActivityService + ) + jest.spyOn(service, 'findOneByIdOrName').mockResolvedValue({ + id: 'MixedCaseBox', + authToken: 'preview-token', + region: 'region-1', + } as any) + + return { service } +} + +describe('BoxService preview URLs', () => { + it('creates case-safe direct preview URLs for service ports', async () => { + const { service } = makePreviewUrlService() + + const result = await service.getPortPreviewUrl('MixedCaseBox', 'org-1', 3000) + + expect(result.boxId).toBe('MixedCaseBox') + expect(result.url).toBe('https://3000-4d6978656443617365426f78.proxy.example.test') + expect(result.token).toBe('preview-token') + }) +}) + describe('BoxService.ensureStartedForProxy', () => { // The control plane never writes box.state directly; like start(), it flips // desiredState and lets the runner's reported state catch up. The proxied diff --git a/apps/api/src/box/services/box.service.ts b/apps/api/src/box/services/box.service.ts index 772279f95..4334f62a2 100644 --- a/apps/api/src/box/services/box.service.ts +++ b/apps/api/src/box/services/box.service.ts @@ -57,7 +57,7 @@ import { customAlphabet as customNanoid, nanoid, urlAlphabet } from 'nanoid' import { WithInstrumentation } from '../../common/decorators/otel.decorator' import { validateMountPaths, validateSubpaths } from '../utils/volume-mount-path-validation.util' import { BoxRepository } from '../repositories/box.repository' -import { PortPreviewUrlDto, SignedPortPreviewUrlDto } from '../dto/port-preview-url.dto' +import { PortPreviewUrlDto } from '../dto/port-preview-url.dto' import { RegionService } from '../../region/services/region.service' import { BoxCreatedEvent } from '../events/box-create.event' import { InjectRedis } from '@nestjs-modules/ioredis' @@ -83,7 +83,6 @@ const DEFAULT_BOX_CPU = 1 const DEFAULT_BOX_MEM = 1 const DEFAULT_BOX_DISK = 10 const DEFAULT_BOX_GPU = 0 -const TERMINAL_PREVIEW_PORT = 22222 @Injectable() export class BoxService { @@ -677,21 +676,18 @@ export class BoxService { if (port < 1 || port > 65535) { throw new BadRequestError('Invalid port') } - if (port !== TERMINAL_PREVIEW_PORT) { - throw new BadRequestError(`Port preview is only supported for terminal port ${TERMINAL_PREVIEW_PORT}`) - } const proxyDomain = this.configService.getOrThrow('proxy.domain') const proxyProtocol = this.configService.getOrThrow('proxy.protocol') const box = await this.findOneByIdOrName(boxIdOrName, organizationId) + const encodedBoxId = encodeDirectPreviewBoxId(box.id) - let url = `${proxyProtocol}://${port}-${box.id}.${proxyDomain}` + let url = `${proxyProtocol}://${port}-${encodedBoxId}.${proxyDomain}` const region = await this.regionService.findOne(box.region, true) if (region && region.proxyUrl) { - // Insert port and box.id into the custom proxy URL - url = region.proxyUrl.replace(/(https?:\/)(\/)/, `$1/${port}-${box.id}.`) + url = region.proxyUrl.replace(/(https?:\/)(\/)/, `$1/${port}-${encodedBoxId}.`) } return { @@ -701,73 +697,6 @@ export class BoxService { } } - async getSignedPortPreviewUrl( - boxIdOrName: string, - organizationId: string, - port: number, - expiresInSeconds = 60, - ): Promise { - if (port < 1 || port > 65535) { - throw new BadRequestError('Invalid port') - } - if (port !== TERMINAL_PREVIEW_PORT) { - throw new BadRequestError(`Signed port preview is only supported for terminal port ${TERMINAL_PREVIEW_PORT}`) - } - - if (expiresInSeconds < 1 || expiresInSeconds > 60 * 60 * 24) { - throw new BadRequestError('expiresInSeconds must be between 1 second and 24 hours') - } - - const proxyDomain = this.configService.getOrThrow('proxy.domain') - const proxyProtocol = this.configService.getOrThrow('proxy.protocol') - - const box = await this.findOneByIdOrName(boxIdOrName, organizationId) - - const token = customNanoid(urlAlphabet.replace('_', '').replace('-', ''))(16).toLocaleLowerCase() - - const lockKey = `box:signed-preview-url-token:${port}:${token}` - await this.redis.setex(lockKey, expiresInSeconds, box.id) - - let url = `${proxyProtocol}://${port}-${token}.${proxyDomain}` - - const region = await this.regionService.findOne(box.region, true) - if (region && region.proxyUrl) { - // Insert port and box.id into the custom proxy URL - url = region.proxyUrl.replace(/(https?:\/)(\/)/, `$1/${port}-${token}.`) - } - - return { - boxId: box.id, - port, - token, - url, - } - } - - async getBoxIdFromSignedPreviewUrlToken(token: string, port: number): Promise { - const lockKey = `box:signed-preview-url-token:${port}:${token}` - const boxId = await this.redis.get(lockKey) - if (!boxId) { - throw new ForbiddenException('Invalid or expired token') - } - return boxId - } - - async expireSignedPreviewUrlToken( - boxIdOrName: string, - organizationId: string, - token: string, - port: number, - ): Promise { - const box = await this.findOneByIdOrName(boxIdOrName, organizationId) - if (!box) { - throw new NotFoundException(`Box with ID or name ${boxIdOrName} not found`) - } - - const lockKey = `box:signed-preview-url-token:${port}:${token}` - await this.redis.del(lockKey) - } - async destroy(boxIdOrName: string, organizationId?: string): Promise { const box = await this.findOneByIdOrName(boxIdOrName, organizationId) @@ -1572,3 +1501,7 @@ export class BoxService { return { valid: true, boxId: sshAccess.box.id } } } + +function encodeDirectPreviewBoxId(boxId: string): string { + return Buffer.from(boxId, 'utf8').toString('hex') +} diff --git a/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.test.tsx b/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.test.tsx index 935a4fe5e..8d38a8cc6 100644 --- a/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.test.tsx +++ b/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.test.tsx @@ -11,13 +11,13 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vite import { useTerminalSessionQuery } from './useTerminalSessionQuery' const mocks = vi.hoisted(() => ({ - getSignedPortPreviewUrl: vi.fn(), + getPortPreviewUrl: vi.fn(), })) vi.mock('@/hooks/useApi', () => ({ useApi: () => ({ boxApi: { - getSignedPortPreviewUrl: mocks.getSignedPortPreviewUrl, + getPortPreviewUrl: mocks.getPortPreviewUrl, }, }), })) @@ -60,9 +60,9 @@ describe('useTerminalSessionQuery', () => { }, }, }) - mocks.getSignedPortPreviewUrl - .mockResolvedValueOnce({ data: { url: 'https://terminal.example/session-1' } }) - .mockResolvedValueOnce({ data: { url: 'https://terminal.example/session-2' } }) + mocks.getPortPreviewUrl + .mockResolvedValueOnce({ data: { url: 'https://terminal.example/session-1', token: 'token-1' } }) + .mockResolvedValueOnce({ data: { url: 'https://terminal.example/session-2?existing=1', token: 'token-2' } }) }) afterEach(() => { @@ -96,26 +96,26 @@ describe('useTerminalSessionQuery', () => { it('keeps the active terminal URL stable across rerenders and refreshes it when re-enabled', async () => { await renderProbe(true) - expect(mocks.getSignedPortPreviewUrl).toHaveBeenCalledTimes(1) + expect(mocks.getPortPreviewUrl).toHaveBeenCalledTimes(1) expect(document.querySelector('[data-testid="terminal-session-url"]')?.textContent).toBe( - 'https://terminal.example/session-1', + 'https://terminal.example/session-1?BOXLITE_BOX_AUTH_KEY=token-1', ) await renderProbe(true) await flushReactWork() - expect(mocks.getSignedPortPreviewUrl).toHaveBeenCalledTimes(1) + expect(mocks.getPortPreviewUrl).toHaveBeenCalledTimes(1) expect(document.querySelector('[data-testid="terminal-session-url"]')?.textContent).toBe( - 'https://terminal.example/session-1', + 'https://terminal.example/session-1?BOXLITE_BOX_AUTH_KEY=token-1', ) await renderProbe(false) await renderProbe(true) await flushReactWork() - expect(mocks.getSignedPortPreviewUrl).toHaveBeenCalledTimes(2) + expect(mocks.getPortPreviewUrl).toHaveBeenCalledTimes(2) expect(document.querySelector('[data-testid="terminal-session-url"]')?.textContent).toBe( - 'https://terminal.example/session-2', + 'https://terminal.example/session-2?existing=1&BOXLITE_BOX_AUTH_KEY=token-2', ) }) }) diff --git a/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.ts b/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.ts index c1628b04e..be8105fc4 100644 --- a/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.ts +++ b/apps/dashboard/src/hooks/queries/useTerminalSessionQuery.ts @@ -25,10 +25,10 @@ export const useTerminalSessionQuery = (boxId: string, enabled: boolean) => { const query = useQuery({ queryKey, queryFn: async (): Promise => { - const url = ( - await boxApi.getSignedPortPreviewUrl(boxId, TERMINAL_PORT, selectedOrganization?.id, SESSION_DURATION_SECONDS) - ).data.url - return { url, expiresAt: Date.now() + SESSION_DURATION_SECONDS * 1000 } + const preview = (await boxApi.getPortPreviewUrl(boxId, TERMINAL_PORT, selectedOrganization?.id)).data + const url = new URL(preview.url) + url.searchParams.set('BOXLITE_BOX_AUTH_KEY', preview.token) + return { url: url.toString(), expiresAt: Date.now() + SESSION_DURATION_SECONDS * 1000 } }, enabled: enabled && !!boxId && !!selectedOrganization?.id, staleTime: 0, diff --git a/apps/infra-local/compose/services.py b/apps/infra-local/compose/services.py index fff438009..e8de3130f 100644 --- a/apps/infra-local/compose/services.py +++ b/apps/infra-local/compose/services.py @@ -420,13 +420,11 @@ def _caddyfile(cfg) -> str: }} :80 {{ -\t# Box port-preview proxy: hostnames look like `-.localhost:28080`. -\t# The dashboard's terminal iframe loads URLs in this shape (returned by -\t# `/api/box/:boxIdOrName/ports/:port/signed-preview-url`). Forward any host that -\t# starts with `-` to the apps/proxy service on the host (port 4000), -\t# which resolves the token → box → runner and proxies through. -\t@signed_port_preview_host header_regexp Host ^[0-9]+-[a-z0-9]+\\. -\thandle @signed_port_preview_host {{ +\t# Box port-preview proxy: hostnames look like `-.localhost:28080`. +\t# Forward any host that starts with `-` to the apps/proxy service on the +\t# host (port 4000), which resolves the encoded box ID → box → runner and proxies through. +\t@port_preview_host header_regexp Host ^[0-9]+-[a-z0-9]+\\. +\thandle @port_preview_host {{ \t\treverse_proxy {cfg.host_hub}:4000 {{ \t\t\theader_up Host {{http.request.host}} \t\t}} diff --git a/apps/libs/api-client/src/.openapi-generator/FILES b/apps/libs/api-client/src/.openapi-generator/FILES index 345c67fb0..8572b69ae 100644 --- a/apps/libs/api-client/src/.openapi-generator/FILES +++ b/apps/libs/api-client/src/.openapi-generator/FILES @@ -123,7 +123,6 @@ docs/RunnerServiceHealth.md docs/RunnerState.md docs/RunnersApi.md docs/SendWebhookDto.md -docs/SignedPortPreviewUrl.md docs/SshAccessDto.md docs/SshAccessValidationDto.md docs/StorageAccessDto.md @@ -242,7 +241,6 @@ models/runner-service-health.ts models/runner-state.ts models/runner.ts models/send-webhook-dto.ts -models/signed-port-preview-url.ts models/ssh-access-dto.ts models/ssh-access-validation-dto.ts models/storage-access-dto.ts diff --git a/apps/libs/api-client/src/api/box-api.ts b/apps/libs/api-client/src/api/box-api.ts index 3bce1bfd1..95a595db8 100644 --- a/apps/libs/api-client/src/api/box-api.ts +++ b/apps/libs/api-client/src/api/box-api.ts @@ -38,8 +38,6 @@ import type { PortPreviewUrl } from '../models'; // @ts-ignore import type { ResizeBox } from '../models'; // @ts-ignore -import type { SignedPortPreviewUrl } from '../models'; -// @ts-ignore import type { SshAccessDto } from '../models'; // @ts-ignore import type { SshAccessValidationDto } from '../models'; @@ -91,57 +89,6 @@ export const BoxApiAxiosParamCreator = function (configuration?: Configuration) localVarHeaderParameter['Accept'] = 'application/json'; - if (xBoxLiteOrganizationID != null) { - localVarHeaderParameter['X-BoxLite-Organization-ID'] = String(xBoxLiteOrganizationID); - } - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Expire signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to expire signed preview URL for - * @param {string} token Token to expire signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - expireSignedPortPreviewUrl: async (boxIdOrName: string, port: number, token: string, xBoxLiteOrganizationID?: string, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'boxIdOrName' is not null or undefined - assertParamExists('expireSignedPortPreviewUrl', 'boxIdOrName', boxIdOrName) - // verify required parameter 'port' is not null or undefined - assertParamExists('expireSignedPortPreviewUrl', 'port', port) - // verify required parameter 'token' is not null or undefined - assertParamExists('expireSignedPortPreviewUrl', 'token', token) - const localVarPath = `/box/{boxIdOrName}/ports/{port}/signed-preview-url/{token}/expire` - .replace('{boxIdOrName}', encodeURIComponent(String(boxIdOrName))) - .replace('{port}', encodeURIComponent(String(port))) - .replace('{token}', encodeURIComponent(String(token))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication bearer required - // http bearer authentication required - await setBearerAuthToObject(localVarHeaderParameter, configuration) - - // authentication oauth2 required - - if (xBoxLiteOrganizationID != null) { localVarHeaderParameter['X-BoxLite-Organization-ID'] = String(xBoxLiteOrganizationID); } @@ -570,59 +517,6 @@ export const BoxApiAxiosParamCreator = function (configuration?: Configuration) options: localVarRequestOptions, }; }, - /** - * - * @summary Get signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to get signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {number} [expiresInSeconds] Expiration time in seconds (default: 60 seconds) - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getSignedPortPreviewUrl: async (boxIdOrName: string, port: number, xBoxLiteOrganizationID?: string, expiresInSeconds?: number, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'boxIdOrName' is not null or undefined - assertParamExists('getSignedPortPreviewUrl', 'boxIdOrName', boxIdOrName) - // verify required parameter 'port' is not null or undefined - assertParamExists('getSignedPortPreviewUrl', 'port', port) - const localVarPath = `/box/{boxIdOrName}/ports/{port}/signed-preview-url` - .replace('{boxIdOrName}', encodeURIComponent(String(boxIdOrName))) - .replace('{port}', encodeURIComponent(String(port))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication bearer required - // http bearer authentication required - await setBearerAuthToObject(localVarHeaderParameter, configuration) - - // authentication oauth2 required - - if (expiresInSeconds !== undefined) { - localVarQueryParameter['expiresInSeconds'] = expiresInSeconds; - } - - localVarHeaderParameter['Accept'] = 'application/json'; - - if (xBoxLiteOrganizationID != null) { - localVarHeaderParameter['X-BoxLite-Organization-ID'] = String(xBoxLiteOrganizationID); - } - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, /** * * @summary Get toolbox proxy URL for a box @@ -1353,22 +1247,6 @@ export const BoxApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['BoxApi.createSshAccess']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, - /** - * - * @summary Expire signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to expire signed preview URL for - * @param {string} token Token to expire signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async expireSignedPortPreviewUrl(boxIdOrName: string, port: number, token: string, xBoxLiteOrganizationID?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.expireSignedPortPreviewUrl(boxIdOrName, port, token, xBoxLiteOrganizationID, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['BoxApi.expireSignedPortPreviewUrl']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, /** * * @summary Get box details @@ -1484,22 +1362,6 @@ export const BoxApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['BoxApi.getPortPreviewUrl']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, - /** - * - * @summary Get signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to get signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {number} [expiresInSeconds] Expiration time in seconds (default: 60 seconds) - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getSignedPortPreviewUrl(boxIdOrName: string, port: number, xBoxLiteOrganizationID?: string, expiresInSeconds?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getSignedPortPreviewUrl(boxIdOrName, port, xBoxLiteOrganizationID, expiresInSeconds, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['BoxApi.getSignedPortPreviewUrl']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, /** * * @summary Get toolbox proxy URL for a box @@ -1729,19 +1591,6 @@ export const BoxApiFactory = function (configuration?: Configuration, basePath?: createSshAccess(boxIdOrName: string, xBoxLiteOrganizationID?: string, expiresInMinutes?: number, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.createSshAccess(boxIdOrName, xBoxLiteOrganizationID, expiresInMinutes, options).then((request) => request(axios, basePath)); }, - /** - * - * @summary Expire signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to expire signed preview URL for - * @param {string} token Token to expire signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - expireSignedPortPreviewUrl(boxIdOrName: string, port: number, token: string, xBoxLiteOrganizationID?: string, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.expireSignedPortPreviewUrl(boxIdOrName, port, token, xBoxLiteOrganizationID, options).then((request) => request(axios, basePath)); - }, /** * * @summary Get box details @@ -1836,19 +1685,6 @@ export const BoxApiFactory = function (configuration?: Configuration, basePath?: getPortPreviewUrl(boxIdOrName: string, port: number, xBoxLiteOrganizationID?: string, options?: RawAxiosRequestConfig): AxiosPromise { return localVarFp.getPortPreviewUrl(boxIdOrName, port, xBoxLiteOrganizationID, options).then((request) => request(axios, basePath)); }, - /** - * - * @summary Get signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to get signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {number} [expiresInSeconds] Expiration time in seconds (default: 60 seconds) - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getSignedPortPreviewUrl(boxIdOrName: string, port: number, xBoxLiteOrganizationID?: string, expiresInSeconds?: number, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.getSignedPortPreviewUrl(boxIdOrName, port, xBoxLiteOrganizationID, expiresInSeconds, options).then((request) => request(axios, basePath)); - }, /** * * @summary Get toolbox proxy URL for a box @@ -2038,19 +1874,6 @@ export class BoxApi extends BaseAPI { return BoxApiFp(this.configuration).createSshAccess(boxIdOrName, xBoxLiteOrganizationID, expiresInMinutes, options).then((request) => request(this.axios, this.basePath)); } - /** - * - * @summary Expire signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to expire signed preview URL for - * @param {string} token Token to expire signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - public expireSignedPortPreviewUrl(boxIdOrName: string, port: number, token: string, xBoxLiteOrganizationID?: string, options?: RawAxiosRequestConfig) { - return BoxApiFp(this.configuration).expireSignedPortPreviewUrl(boxIdOrName, port, token, xBoxLiteOrganizationID, options).then((request) => request(this.axios, this.basePath)); - } /** * @@ -2153,19 +1976,6 @@ export class BoxApi extends BaseAPI { return BoxApiFp(this.configuration).getPortPreviewUrl(boxIdOrName, port, xBoxLiteOrganizationID, options).then((request) => request(this.axios, this.basePath)); } - /** - * - * @summary Get signed preview URL for a box port - * @param {string} boxIdOrName ID or name of the box - * @param {number} port Port number to get signed preview URL for - * @param {string} [xBoxLiteOrganizationID] Use with JWT to specify the organization ID - * @param {number} [expiresInSeconds] Expiration time in seconds (default: 60 seconds) - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - public getSignedPortPreviewUrl(boxIdOrName: string, port: number, xBoxLiteOrganizationID?: string, expiresInSeconds?: number, options?: RawAxiosRequestConfig) { - return BoxApiFp(this.configuration).getSignedPortPreviewUrl(boxIdOrName, port, xBoxLiteOrganizationID, expiresInSeconds, options).then((request) => request(this.axios, this.basePath)); - } /** * diff --git a/apps/libs/api-client/src/api/preview-api.ts b/apps/libs/api-client/src/api/preview-api.ts index 5607fda86..4407ad201 100644 --- a/apps/libs/api-client/src/api/preview-api.ts +++ b/apps/libs/api-client/src/api/preview-api.ts @@ -26,44 +26,6 @@ import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError */ export const PreviewApiAxiosParamCreator = function (configuration?: Configuration) { return { - /** - * - * @summary Get box ID from signed preview URL token - * @param {string} signedPreviewToken Signed preview URL token - * @param {number} port Port number to get box ID from signed preview URL token - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getBoxIdFromSignedPreviewUrlToken: async (signedPreviewToken: string, port: number, options: RawAxiosRequestConfig = {}): Promise => { - // verify required parameter 'signedPreviewToken' is not null or undefined - assertParamExists('getBoxIdFromSignedPreviewUrlToken', 'signedPreviewToken', signedPreviewToken) - // verify required parameter 'port' is not null or undefined - assertParamExists('getBoxIdFromSignedPreviewUrlToken', 'port', port) - const localVarPath = `/preview/{signedPreviewToken}/{port}/box-id` - .replace('{signedPreviewToken}', encodeURIComponent(String(signedPreviewToken))) - .replace('{port}', encodeURIComponent(String(port))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - localVarHeaderParameter['Accept'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, /** * * @summary Check if user has access to the box @@ -185,20 +147,6 @@ export const PreviewApiAxiosParamCreator = function (configuration?: Configurati export const PreviewApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = PreviewApiAxiosParamCreator(configuration) return { - /** - * - * @summary Get box ID from signed preview URL token - * @param {string} signedPreviewToken Signed preview URL token - * @param {number} port Port number to get box ID from signed preview URL token - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async getBoxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.getBoxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options); - const localVarOperationServerIndex = configuration?.serverIndex ?? 0; - const localVarOperationServerBasePath = operationServerMap['PreviewApi.getBoxIdFromSignedPreviewUrlToken']?.[localVarOperationServerIndex]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); - }, /** * * @summary Check if user has access to the box @@ -248,17 +196,6 @@ export const PreviewApiFp = function(configuration?: Configuration) { export const PreviewApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = PreviewApiFp(configuration) return { - /** - * - * @summary Get box ID from signed preview URL token - * @param {string} signedPreviewToken Signed preview URL token - * @param {number} port Port number to get box ID from signed preview URL token - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - getBoxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp.getBoxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options).then((request) => request(axios, basePath)); - }, /** * * @summary Check if user has access to the box @@ -297,17 +234,6 @@ export const PreviewApiFactory = function (configuration?: Configuration, basePa * PreviewApi - object-oriented interface */ export class PreviewApi extends BaseAPI { - /** - * - * @summary Get box ID from signed preview URL token - * @param {string} signedPreviewToken Signed preview URL token - * @param {number} port Port number to get box ID from signed preview URL token - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - public getBoxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig) { - return PreviewApiFp(this.configuration).getBoxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options).then((request) => request(this.axios, this.basePath)); - } /** * diff --git a/apps/libs/api-client/src/docs/BoxApi.md b/apps/libs/api-client/src/docs/BoxApi.md index 9d419e07e..7365644f8 100644 --- a/apps/libs/api-client/src/docs/BoxApi.md +++ b/apps/libs/api-client/src/docs/BoxApi.md @@ -5,7 +5,6 @@ All URIs are relative to *http://localhost:3000* |Method | HTTP request | Description| |------------- | ------------- | -------------| |[**createSshAccess**](#createsshaccess) | **POST** /box/{boxIdOrName}/ssh-access | Create SSH access for box| -|[**expireSignedPortPreviewUrl**](#expiresignedportpreviewurl) | **POST** /box/{boxIdOrName}/ports/{port}/signed-preview-url/{token}/expire | Expire signed preview URL for a box port| |[**getBox**](#getbox) | **GET** /box/{boxIdOrName} | Get box details| |[**getBoxLogs**](#getboxlogs) | **GET** /box/{boxId}/telemetry/logs | Get box logs| |[**getBoxMetrics**](#getboxmetrics) | **GET** /box/{boxId}/telemetry/metrics | Get box metrics| @@ -13,7 +12,6 @@ All URIs are relative to *http://localhost:3000* |[**getBoxTraces**](#getboxtraces) | **GET** /box/{boxId}/telemetry/traces | Get box traces| |[**getBoxesForRunner**](#getboxesforrunner) | **GET** /box/for-runner | Get boxes for the authenticated runner| |[**getPortPreviewUrl**](#getportpreviewurl) | **GET** /box/{boxIdOrName}/ports/{port}/preview-url | Get preview URL for a box port| -|[**getSignedPortPreviewUrl**](#getsignedportpreviewurl) | **GET** /box/{boxIdOrName}/ports/{port}/signed-preview-url | Get signed preview URL for a box port| |[**getToolboxProxyUrl**](#gettoolboxproxyurl) | **GET** /box/{boxId}/toolbox-proxy-url | Get toolbox proxy URL for a box| |[**listBoxes**](#listboxes) | **GET** /box | List all boxes| |[**listBoxesPaginated**](#listboxespaginated) | **GET** /box/paginated | List all boxes paginated| @@ -84,64 +82,6 @@ const { status, data } = await apiInstance.createSshAccess( [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **expireSignedPortPreviewUrl** -> expireSignedPortPreviewUrl() - - -### Example - -```typescript -import { - BoxApi, - Configuration -} from './api'; - -const configuration = new Configuration(); -const apiInstance = new BoxApi(configuration); - -let boxIdOrName: string; //ID or name of the box (default to undefined) -let port: number; //Port number to expire signed preview URL for (default to undefined) -let token: string; //Token to expire signed preview URL for (default to undefined) -let xBoxLiteOrganizationID: string; //Use with JWT to specify the organization ID (optional) (default to undefined) - -const { status, data } = await apiInstance.expireSignedPortPreviewUrl( - boxIdOrName, - port, - token, - xBoxLiteOrganizationID -); -``` - -### Parameters - -|Name | Type | Description | Notes| -|------------- | ------------- | ------------- | -------------| -| **boxIdOrName** | [**string**] | ID or name of the box | defaults to undefined| -| **port** | [**number**] | Port number to expire signed preview URL for | defaults to undefined| -| **token** | [**string**] | Token to expire signed preview URL for | defaults to undefined| -| **xBoxLiteOrganizationID** | [**string**] | Use with JWT to specify the organization ID | (optional) defaults to undefined| - - -### Return type - -void (empty response body) - -### Authorization - -[bearer](../README.md#bearer), [oauth2](../README.md#oauth2) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -|**200** | Signed preview URL has been expired | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getBox** > Box getBox() @@ -569,64 +509,6 @@ const { status, data } = await apiInstance.getPortPreviewUrl( [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **getSignedPortPreviewUrl** -> SignedPortPreviewUrl getSignedPortPreviewUrl() - - -### Example - -```typescript -import { - BoxApi, - Configuration -} from './api'; - -const configuration = new Configuration(); -const apiInstance = new BoxApi(configuration); - -let boxIdOrName: string; //ID or name of the box (default to undefined) -let port: number; //Port number to get signed preview URL for (default to undefined) -let xBoxLiteOrganizationID: string; //Use with JWT to specify the organization ID (optional) (default to undefined) -let expiresInSeconds: number; //Expiration time in seconds (default: 60 seconds) (optional) (default to undefined) - -const { status, data } = await apiInstance.getSignedPortPreviewUrl( - boxIdOrName, - port, - xBoxLiteOrganizationID, - expiresInSeconds -); -``` - -### Parameters - -|Name | Type | Description | Notes| -|------------- | ------------- | ------------- | -------------| -| **boxIdOrName** | [**string**] | ID or name of the box | defaults to undefined| -| **port** | [**number**] | Port number to get signed preview URL for | defaults to undefined| -| **xBoxLiteOrganizationID** | [**string**] | Use with JWT to specify the organization ID | (optional) defaults to undefined| -| **expiresInSeconds** | [**number**] | Expiration time in seconds (default: 60 seconds) | (optional) defaults to undefined| - - -### Return type - -**SignedPortPreviewUrl** - -### Authorization - -[bearer](../README.md#bearer), [oauth2](../README.md#oauth2) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -|**200** | Signed preview URL for the specified port | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **getToolboxProxyUrl** > ToolboxProxyUrl getToolboxProxyUrl() diff --git a/apps/libs/api-client/src/docs/PreviewApi.md b/apps/libs/api-client/src/docs/PreviewApi.md index 0f78f8cf4..205b72d2d 100644 --- a/apps/libs/api-client/src/docs/PreviewApi.md +++ b/apps/libs/api-client/src/docs/PreviewApi.md @@ -4,63 +4,10 @@ All URIs are relative to *http://localhost:3000* |Method | HTTP request | Description| |------------- | ------------- | -------------| -|[**getBoxIdFromSignedPreviewUrlToken**](#getboxidfromsignedpreviewurltoken) | **GET** /preview/{signedPreviewToken}/{port}/box-id | Get box ID from signed preview URL token| |[**hasBoxAccess**](#hasboxaccess) | **GET** /preview/{boxId}/access | Check if user has access to the box| |[**isBoxPublic**](#isboxpublic) | **GET** /preview/{boxId}/public | Check if box is public| |[**isValidAuthToken**](#isvalidauthtoken) | **GET** /preview/{boxId}/validate/{authToken} | Check if box auth token is valid| -# **getBoxIdFromSignedPreviewUrlToken** -> string getBoxIdFromSignedPreviewUrlToken() - - -### Example - -```typescript -import { - PreviewApi, - Configuration -} from './api'; - -const configuration = new Configuration(); -const apiInstance = new PreviewApi(configuration); - -let signedPreviewToken: string; //Signed preview URL token (default to undefined) -let port: number; //Port number to get box ID from signed preview URL token (default to undefined) - -const { status, data } = await apiInstance.getBoxIdFromSignedPreviewUrlToken( - signedPreviewToken, - port -); -``` - -### Parameters - -|Name | Type | Description | Notes| -|------------- | ------------- | ------------- | -------------| -| **signedPreviewToken** | [**string**] | Signed preview URL token | defaults to undefined| -| **port** | [**number**] | Port number to get box ID from signed preview URL token | defaults to undefined| - - -### Return type - -**string** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -|**200** | Box ID from signed preview URL token | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **hasBoxAccess** > boolean hasBoxAccess() diff --git a/apps/libs/api-client/src/docs/SignedPortPreviewUrl.md b/apps/libs/api-client/src/docs/SignedPortPreviewUrl.md deleted file mode 100644 index 8b89e3e4e..000000000 --- a/apps/libs/api-client/src/docs/SignedPortPreviewUrl.md +++ /dev/null @@ -1,26 +0,0 @@ -# SignedPortPreviewUrl - - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**boxId** | **string** | ID of the box | [default to undefined] -**port** | **number** | Port number of the signed preview URL | [default to undefined] -**token** | **string** | Token of the signed preview URL | [default to undefined] -**url** | **string** | Signed preview url | [default to undefined] - -## Example - -```typescript -import { SignedPortPreviewUrl } from './api'; - -const instance: SignedPortPreviewUrl = { - boxId, - port, - token, - url, -}; -``` - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/apps/libs/api-client/src/models/index.ts b/apps/libs/api-client/src/models/index.ts index ce9e1efad..cc7254415 100644 --- a/apps/libs/api-client/src/models/index.ts +++ b/apps/libs/api-client/src/models/index.ts @@ -87,7 +87,6 @@ export * from './runner-healthcheck'; export * from './runner-service-health'; export * from './runner-state'; export * from './send-webhook-dto'; -export * from './signed-port-preview-url'; export * from './ssh-access-dto'; export * from './ssh-access-validation-dto'; export * from './storage-access-dto'; diff --git a/apps/libs/api-client/src/models/signed-port-preview-url.ts b/apps/libs/api-client/src/models/signed-port-preview-url.ts deleted file mode 100644 index 1d080f1f0..000000000 --- a/apps/libs/api-client/src/models/signed-port-preview-url.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * BoxLite - * BoxLite AI platform API Docs - * - * The version of the OpenAPI document: 1.0 - * Contact: support@boxlite.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - - -export interface SignedPortPreviewUrl { - /** - * ID of the box - */ - 'boxId': string; - /** - * Port number of the signed preview URL - */ - 'port': number; - /** - * Token of the signed preview URL - */ - 'token': string; - /** - * Signed preview url - */ - 'url': string; -} - diff --git a/apps/proxy/pkg/proxy/auth.go b/apps/proxy/pkg/proxy/auth.go index 060319d66..5ab782fb9 100644 --- a/apps/proxy/pkg/proxy/auth.go +++ b/apps/proxy/pkg/proxy/auth.go @@ -11,21 +11,20 @@ import ( "strings" common_errors "github.com/boxlite-ai/common-go/pkg/errors" - "github.com/boxlite-ai/common-go/pkg/utils" "github.com/gin-gonic/gin" ) -func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port float32) (boxId string, didRedirect bool, err error) { +func (p *Proxy) Authenticate(ctx *gin.Context, boxId string, port float32) (string, bool, error) { var authErrors []string // Try Authorization header with Bearer token bearerToken := p.getBearerToken(ctx) if bearerToken != "" { - isValid, err := p.getBoxBearerTokenValid(ctx, boxIdOrSignedToken, bearerToken) + isValid, err := p.getBoxBearerTokenValid(ctx, boxId, bearerToken) if err != nil { authErrors = append(authErrors, fmt.Sprintf("Bearer token validation error: %v", err)) } else if isValid != nil && *isValid { - return boxIdOrSignedToken, false, nil + return boxId, false, nil } else { authErrors = append(authErrors, "Bearer token is invalid") } @@ -35,11 +34,11 @@ func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port f authKey := ctx.Request.Header.Get(BOX_AUTH_KEY_HEADER) if authKey != "" { ctx.Request.Header.Del(BOX_AUTH_KEY_HEADER) - isValid, err := p.getBoxAuthKeyValid(ctx, boxIdOrSignedToken, authKey) + isValid, err := p.getBoxAuthKeyValid(ctx, boxId, authKey) if err != nil { authErrors = append(authErrors, fmt.Sprintf("Auth key header validation error: %v", err)) } else if isValid != nil && *isValid { - return boxIdOrSignedToken, false, nil + return boxId, false, nil } else { authErrors = append(authErrors, "Auth key header is invalid") } @@ -48,7 +47,7 @@ func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port f // Try auth key from query parameter queryAuthKey := ctx.Query(BOX_AUTH_KEY_QUERY_PARAM) if queryAuthKey != "" { - isValid, err := p.getBoxAuthKeyValid(ctx, boxIdOrSignedToken, queryAuthKey) + isValid, err := p.getBoxAuthKeyValid(ctx, boxId, queryAuthKey) if err != nil { authErrors = append(authErrors, fmt.Sprintf("Auth key query param validation error: %v", err)) } else if isValid != nil && *isValid { @@ -56,17 +55,17 @@ func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port f newQuery := ctx.Request.URL.Query() newQuery.Del(BOX_AUTH_KEY_QUERY_PARAM) ctx.Request.URL.RawQuery = newQuery.Encode() - return boxIdOrSignedToken, false, nil + return boxId, false, nil } else { authErrors = append(authErrors, "Auth key query parameter is invalid") } } // Try cookie authentication - cookieBoxId, err := ctx.Cookie(BOX_AUTH_COOKIE_NAME + boxIdOrSignedToken) + cookieBoxId, err := ctx.Cookie(BOX_AUTH_COOKIE_NAME + boxId) if err == nil && cookieBoxId != "" { decodedValue := "" - err = p.secureCookie.Decode(BOX_AUTH_COOKIE_NAME+boxIdOrSignedToken, cookieBoxId, &decodedValue) + err = p.secureCookie.Decode(BOX_AUTH_COOKIE_NAME+boxId, cookieBoxId, &decodedValue) if err != nil { authErrors = append(authErrors, fmt.Sprintf("Cookie decoding error: %v", err)) } else { @@ -74,18 +73,10 @@ func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port f } } - cookieDomain := p.getCookieDomain(ctx.Request.Host) - boxId, err = p.getBoxIdFromSignedPreviewUrlToken(ctx, boxIdOrSignedToken, port, cookieDomain) - if err == nil { - return boxId, false, nil - } else { - authErrors = append(authErrors, err.Error()) - } - // All authentication methods failed, redirect to auth URL - authUrl, err := p.getAuthUrl(ctx, boxIdOrSignedToken) + authUrl, err := p.getAuthUrl(ctx, boxId) if err != nil { - return boxIdOrSignedToken, false, fmt.Errorf("failed to get auth URL: %w", err) + return boxId, false, fmt.Errorf("failed to get auth URL: %w", err) } ctx.Redirect(http.StatusTemporaryRedirect, authUrl) @@ -98,7 +89,7 @@ func (p *Proxy) Authenticate(ctx *gin.Context, boxIdOrSignedToken string, port f errorMsg = "missing authentication: provide a preview access token (via header, query parameter, or cookie) or use an API key or JWT" } - return boxIdOrSignedToken, true, common_errors.NewUnauthorizedError(errors.New(errorMsg)) + return boxId, true, common_errors.NewUnauthorizedError(errors.New(errorMsg)) } func (p *Proxy) getBearerToken(ctx *gin.Context) string { @@ -108,30 +99,3 @@ func (p *Proxy) getBearerToken(ctx *gin.Context) string { } return "" } - -func (p *Proxy) getBoxIdFromSignedPreviewUrlToken(ctx *gin.Context, boxIdOrSignedToken string, port float32, cookieDomain string) (string, error) { - var boxId string - err := utils.RetryWithExponentialBackoff(ctx.Request.Context(), "getBoxIdFromSignedPreviewUrlToken", proxyMaxRetries, proxyBaseDelay, proxyMaxDelay, func() error { - s, _, e := p.apiclient.PreviewAPI.GetBoxIdFromSignedPreviewUrlToken(ctx.Request.Context(), boxIdOrSignedToken, port).Execute() - boxId = s - openapiErr := common_errors.ConvertOpenAPIError(e) - - if openapiErr != nil && !common_errors.IsRetryableOpenAPIError(openapiErr) { - return &utils.NonRetryableError{Err: openapiErr} - } - - return openapiErr - }) - if err != nil { - return "", err - } - - encoded, err := p.secureCookie.Encode(BOX_AUTH_COOKIE_NAME+boxIdOrSignedToken, boxId) - if err != nil { - return "", fmt.Errorf("failed to encode cookie: %w", err) - } - - ctx.SetCookie(BOX_AUTH_COOKIE_NAME+boxIdOrSignedToken, encoded, 3600, "/", cookieDomain, p.config.EnableTLS, true) - - return boxId, nil -} diff --git a/apps/proxy/pkg/proxy/get_box_target.go b/apps/proxy/pkg/proxy/get_box_target.go index a7fd9abbd..0628696b7 100644 --- a/apps/proxy/pkg/proxy/get_box_target.go +++ b/apps/proxy/pkg/proxy/get_box_target.go @@ -6,6 +6,7 @@ package proxy import ( "context" + "encoding/hex" "errors" "fmt" "net/http" @@ -22,13 +23,18 @@ import ( log "github.com/sirupsen/logrus" ) +const ( + directPreviewBoxIDLength = 12 + encodedDirectPreviewBoxIDLength = 24 +) + func (p *Proxy) GetProxyTarget(ctx *gin.Context) (*url.URL, map[string]string, error) { - var targetPort, targetPath, boxIdOrSignedToken string + var targetPort, targetPath, encodedBoxID string // Extract port and box ID from the host header. - // Expected format: 1234-.proxy.domain + // Expected format: 1234-.proxy.domain var err error - targetPort, boxIdOrSignedToken, _, err = p.parseHost(ctx.Request.Host) + targetPort, encodedBoxID, _, err = p.parseHost(ctx.Request.Host) if err != nil { ctx.Error(common_errors.NewBadRequestError(err)) return nil, nil, err @@ -40,14 +46,18 @@ func (p *Proxy) GetProxyTarget(ctx *gin.Context) (*url.URL, map[string]string, e return nil, nil, errors.New("target port is required") } - if boxIdOrSignedToken == "" { - ctx.Error(common_errors.NewBadRequestError(errors.New("box ID or signed token is required"))) - return nil, nil, errors.New("box ID or signed token is required") + if encodedBoxID == "" { + ctx.Error(common_errors.NewBadRequestError(errors.New("encoded box ID is required"))) + return nil, nil, errors.New("encoded box ID is required") } - boxId := boxIdOrSignedToken + boxId, decodeErr := decodeDirectPreviewBoxID(encodedBoxID) + if decodeErr != nil { + ctx.Error(common_errors.NewBadRequestError(decodeErr)) + return nil, nil, decodeErr + } - isPublic, err := p.getBoxPublic(ctx, boxIdOrSignedToken) + isPublic, err := p.getBoxPublic(ctx, boxId) if err != nil { ctx.Error(common_errors.NewBadRequestError(fmt.Errorf("failed to get box public status: %w", err))) return nil, nil, fmt.Errorf("failed to get box public status: %w", err) @@ -60,7 +70,7 @@ func (p *Proxy) GetProxyTarget(ctx *gin.Context) (*url.URL, map[string]string, e return nil, nil, fmt.Errorf("failed to parse target port: %w", err) } var didRedirect bool - boxId, didRedirect, err = p.Authenticate(ctx, boxIdOrSignedToken, float32(portFloat)) + boxId, didRedirect, err = p.Authenticate(ctx, boxId, float32(portFloat)) if err != nil { if !didRedirect { ctx.Error(err) @@ -251,7 +261,7 @@ func (p *Proxy) validateAndCache( return &isValid, nil } -func (p *Proxy) parseHost(host string) (targetPort string, boxIdOrSignedToken string, baseHost string, err error) { +func (p *Proxy) parseHost(host string) (targetPort string, encodedBoxID string, baseHost string, err error) { // Extract port and box ID from the host header // Expected format: 1234-some-id-uuid.proxy.domain if host == "" { @@ -282,11 +292,42 @@ func (p *Proxy) parseHost(host string) (targetPort string, boxIdOrSignedToken st return "", "", "", fmt.Errorf("invalid port '%s': must be numeric", targetPort) } - boxIdOrSignedToken = after + encodedBoxID = after // Join remaining parts to form the base domain (e.g., "proxy.domain") baseHost = strings.Join(parts[1:], ".") - return targetPort, boxIdOrSignedToken, baseHost, nil + return targetPort, encodedBoxID, baseHost, nil +} + +func decodeDirectPreviewBoxID(value string) (string, error) { + if len(value) != encodedDirectPreviewBoxIDLength { + return "", fmt.Errorf("invalid encoded box ID length: got %d, want %d", len(value), encodedDirectPreviewBoxIDLength) + } + + decoded, err := hex.DecodeString(value) + if err != nil { + return "", fmt.Errorf("invalid encoded box ID: %w", err) + } + + boxId := string(decoded) + if !isValidDirectPreviewBoxID(boxId) { + return "", errors.New("invalid direct preview box ID") + } + + return boxId, nil +} + +func isValidDirectPreviewBoxID(value string) bool { + if len(value) != directPreviewBoxIDLength { + return false + } + for _, ch := range value { + if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') { + continue + } + return false + } + return true } // updateLastActivity updates the last activity timestamp for a box. diff --git a/apps/proxy/pkg/proxy/get_box_target_test.go b/apps/proxy/pkg/proxy/get_box_target_test.go new file mode 100644 index 000000000..5172bbb0a --- /dev/null +++ b/apps/proxy/pkg/proxy/get_box_target_test.go @@ -0,0 +1,25 @@ +// Copyright 2026 BoxLite AI +// SPDX-License-Identifier: AGPL-3.0 + +package proxy + +import "testing" + +func TestDecodeDirectPreviewBoxID(t *testing.T) { + boxID := "53MOZ3jp5Zu1" + encoded := "35334d4f5a336a70355a7531" + + decoded, err := decodeDirectPreviewBoxID(encoded) + if err != nil { + t.Fatalf("decodeDirectPreviewBoxID returned error: %v", err) + } + if decoded != boxID { + t.Fatalf("decodeDirectPreviewBoxID = %q, want %q", decoded, boxID) + } +} + +func TestDecodeDirectPreviewBoxIDRejectsSignedLikeToken(t *testing.T) { + if _, err := decodeDirectPreviewBoxID("signedtoken12345"); err == nil { + t.Fatal("decodeDirectPreviewBoxID accepted a signed-token-like value") + } +}