mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
938 lines
32 KiB
Go
938 lines
32 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
// CodeAPIService CodeAPI service
|
|
type CodeAPIService service
|
|
|
|
type CodeAPIGetCodeAskRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
q *string
|
|
repo *string
|
|
}
|
|
|
|
// Q is the question to answer. Required, max 4000 bytes.
|
|
func (r CodeAPIGetCodeAskRequest) Q(q string) CodeAPIGetCodeAskRequest {
|
|
r.q = &q
|
|
return r
|
|
}
|
|
|
|
// Repo narrows retrieval to one repository. Empty searches every repo the org has indexed.
|
|
func (r CodeAPIGetCodeAskRequest) Repo(repo string) CodeAPIGetCodeAskRequest {
|
|
r.repo = &repo
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIGetCodeAskRequest) Execute() (*CodeAskAnswer, *http.Response, error) {
|
|
return r.ApiService.GetCodeAskExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCodeAsk Answers a question about the caller org's code with a CITED answer: retrieval packs grounding context, then the synthesizer writes the answer over exactly those spans, which come back alongside it.
|
|
|
|
Answers a question about the caller org's code with a CITED answer:
|
|
retrieval packs grounding context, then the synthesizer writes the answer over
|
|
exactly those spans, which come back alongside it. It never answers without
|
|
grounding — with no matched code the answer is empty and says so, and with no
|
|
synthesizer available the citations still come back with "degraded": true so
|
|
the caller can reason over the spans itself.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIGetCodeAskRequest
|
|
*/
|
|
func (a *CodeAPIService) GetCodeAsk(ctx context.Context) CodeAPIGetCodeAskRequest {
|
|
return CodeAPIGetCodeAskRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeAskAnswer
|
|
func (a *CodeAPIService) GetCodeAskExecute(r CodeAPIGetCodeAskRequest) (*CodeAskAnswer, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeAskAnswer
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.GetCodeAsk")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/ask"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.q != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "q", r.q, "form", "")
|
|
}
|
|
if r.repo != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "repo", r.repo, "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", "application/problem+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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIGetCodeFileRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
path *string
|
|
repo *string
|
|
}
|
|
|
|
// Path is the file's repo-relative path. Required.
|
|
func (r CodeAPIGetCodeFileRequest) Path(path string) CodeAPIGetCodeFileRequest {
|
|
r.path = &path
|
|
return r
|
|
}
|
|
|
|
// Repo is the repository the file belongs to. REQUIRED.
|
|
func (r CodeAPIGetCodeFileRequest) Repo(repo string) CodeAPIGetCodeFileRequest {
|
|
r.repo = &repo
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIGetCodeFileRequest) Execute() (*CodeFileContent, *http.Response, error) {
|
|
return r.ApiService.GetCodeFileExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCodeFile Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found.
|
|
|
|
Returns the INDEXED content of one file — read_file over the chunks the
|
|
search tiers hold, for pulling up code an agent just found. It is NOT
|
|
byte-verbatim: the git object plane is the source of record for exact bytes,
|
|
history and blame. A file absent from the index is a 404, so an agent can tell
|
|
"not indexed" from "empty file".
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIGetCodeFileRequest
|
|
*/
|
|
func (a *CodeAPIService) GetCodeFile(ctx context.Context) CodeAPIGetCodeFileRequest {
|
|
return CodeAPIGetCodeFileRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeFileContent
|
|
func (a *CodeAPIService) GetCodeFileExecute(r CodeAPIGetCodeFileRequest) (*CodeFileContent, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeFileContent
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.GetCodeFile")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/file"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.path != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "path", r.path, "form", "")
|
|
}
|
|
if r.repo != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "repo", r.repo, "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", "application/problem+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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIGetCodeSearchRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
q *string
|
|
type_ *string
|
|
repo *string
|
|
limit *int64
|
|
}
|
|
|
|
// Q is the search query. Required, max 4000 bytes. For type=regex it is a regular expression; for type=symbol it is a symbol name.
|
|
func (r CodeAPIGetCodeSearchRequest) Q(q string) CodeAPIGetCodeSearchRequest {
|
|
r.q = &q
|
|
return r
|
|
}
|
|
|
|
// Type selects the retrieval tier: \"text\" (FTS5 trigram), \"regex\", \"symbol\" (definitions), \"semantic\" (embeddings) or \"hybrid\". Anything else — including empty — reads as hybrid.
|
|
func (r CodeAPIGetCodeSearchRequest) Type_(type_ string) CodeAPIGetCodeSearchRequest {
|
|
r.type_ = &type_
|
|
return r
|
|
}
|
|
|
|
// Repo narrows to one repository. Empty searches every repo the org has indexed.
|
|
func (r CodeAPIGetCodeSearchRequest) Repo(repo string) CodeAPIGetCodeSearchRequest {
|
|
r.repo = &repo
|
|
return r
|
|
}
|
|
|
|
// Limit caps how many spans come back: default 20, maximum 100. A value that is not a positive integer reads as the default.
|
|
func (r CodeAPIGetCodeSearchRequest) Limit(limit int64) CodeAPIGetCodeSearchRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIGetCodeSearchRequest) Execute() (*CodeSearchResults, *http.Response, error) {
|
|
return r.ApiService.GetCodeSearchExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCodeSearch Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized text), symbolic (real definition and reference edges), and semantic (embedding cosine over AST-boundary chunks).
|
|
|
|
Finds code in the caller org's index across three orthogonal retrieval
|
|
tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over
|
|
code-tokenized text), symbolic (real definition and reference edges), and
|
|
semantic (embedding cosine over AST-boundary chunks). Pick one tier with
|
|
`type`, or leave it to run all three as hybrid, which is what a coding agent
|
|
usually wants. It is FAIL-HONEST: a retrieval outage answers 200 with an empty
|
|
result set and "degraded": true rather than a 5xx, so an agent degrades instead
|
|
of stalling. A malformed regex is a 400.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIGetCodeSearchRequest
|
|
*/
|
|
func (a *CodeAPIService) GetCodeSearch(ctx context.Context) CodeAPIGetCodeSearchRequest {
|
|
return CodeAPIGetCodeSearchRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeSearchResults
|
|
func (a *CodeAPIService) GetCodeSearchExecute(r CodeAPIGetCodeSearchRequest) (*CodeSearchResults, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeSearchResults
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.GetCodeSearch")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/search"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.q != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "q", r.q, "form", "")
|
|
}
|
|
if r.type_ != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "type", r.type_, "form", "")
|
|
}
|
|
if r.repo != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "repo", r.repo, "form", "")
|
|
}
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "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", "application/problem+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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIGetCodeTreeRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
repo *string
|
|
}
|
|
|
|
// Repo is the repository to walk. REQUIRED — a tree is repo-scoped.
|
|
func (r CodeAPIGetCodeTreeRequest) Repo(repo string) CodeAPIGetCodeTreeRequest {
|
|
r.repo = &repo
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIGetCodeTreeRequest) Execute() (*CodeRepoTree, *http.Response, error) {
|
|
return r.ApiService.GetCodeTreeExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetCodeTree Returns one repository's file structure with a per-file symbol count — get_repo_structure over the org's own index, with no git checkout involved.
|
|
|
|
Returns one repository's file structure with a per-file symbol count —
|
|
get_repo_structure over the org's own index, with no git checkout involved. A
|
|
repository that has not been indexed answers an empty tree rather than an
|
|
error, so an agent can tell "nothing here" without handling a failure.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIGetCodeTreeRequest
|
|
*/
|
|
func (a *CodeAPIService) GetCodeTree(ctx context.Context) CodeAPIGetCodeTreeRequest {
|
|
return CodeAPIGetCodeTreeRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeRepoTree
|
|
func (a *CodeAPIService) GetCodeTreeExecute(r CodeAPIGetCodeTreeRequest) (*CodeRepoTree, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeRepoTree
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.GetCodeTree")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/tree"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.repo != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "repo", r.repo, "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", "application/problem+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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIPostCodeAskRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
codeAskPostIn *CodeAskPostIn
|
|
}
|
|
|
|
func (r CodeAPIPostCodeAskRequest) CodeAskPostIn(codeAskPostIn CodeAskPostIn) CodeAPIPostCodeAskRequest {
|
|
r.codeAskPostIn = &codeAskPostIn
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIPostCodeAskRequest) Execute() (*CodeAskAnswer, *http.Response, error) {
|
|
return r.ApiService.PostCodeAskExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostCodeAsk Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL.
|
|
|
|
Answers a question about the caller org's code with a CITED answer,
|
|
taking the question from the request BODY, for a question too long or too
|
|
awkward to put in a URL. `query` and `repo` in the body take precedence over
|
|
`?q=` and `?repo=`; either source works alone.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIPostCodeAskRequest
|
|
*/
|
|
func (a *CodeAPIService) PostCodeAsk(ctx context.Context) CodeAPIPostCodeAskRequest {
|
|
return CodeAPIPostCodeAskRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeAskAnswer
|
|
func (a *CodeAPIService) PostCodeAskExecute(r CodeAPIPostCodeAskRequest) (*CodeAskAnswer, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeAskAnswer
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.PostCodeAsk")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/ask"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.codeAskPostIn == nil {
|
|
return localVarReturnValue, nil, reportError("codeAskPostIn is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.codeAskPostIn
|
|
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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIPostCodeContextRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
codeContextIn *CodeContextIn
|
|
}
|
|
|
|
func (r CodeAPIPostCodeContextRequest) CodeContextIn(codeContextIn CodeContextIn) CodeAPIPostCodeContextRequest {
|
|
r.codeContextIn = &codeContextIn
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIPostCodeContextRequest) Execute() (*CodeContextBundle, *http.Response, error) {
|
|
return r.ApiService.PostCodeContextExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostCodeContext Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt.
|
|
|
|
Packs the most relevant code for a query into a token budget — THE
|
|
primitive for a coding agent that has to decide what to put in a prompt. It
|
|
retrieves seed spans, expands each with the definitions it calls and its key
|
|
callers, then greedily fills the budget, so the answer is a coherent slice of
|
|
the codebase rather than a list of disconnected matches. The top match is
|
|
always included, truncated if it alone overflows, so a matched query never
|
|
comes back empty. A retrieval outage answers 200 with an empty bundle rather
|
|
than a 5xx.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIPostCodeContextRequest
|
|
*/
|
|
func (a *CodeAPIService) PostCodeContext(ctx context.Context) CodeAPIPostCodeContextRequest {
|
|
return CodeAPIPostCodeContextRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeContextBundle
|
|
func (a *CodeAPIService) PostCodeContextExecute(r CodeAPIPostCodeContextRequest) (*CodeContextBundle, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeContextBundle
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.PostCodeContext")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/context"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.codeContextIn == nil {
|
|
return localVarReturnValue, nil, reportError("codeContextIn is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.codeContextIn
|
|
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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type CodeAPIPostCodeIndexRequest struct {
|
|
ctx context.Context
|
|
ApiService *CodeAPIService
|
|
codeIndexIn *CodeIndexIn
|
|
}
|
|
|
|
func (r CodeAPIPostCodeIndexRequest) CodeIndexIn(codeIndexIn CodeIndexIn) CodeAPIPostCodeIndexRequest {
|
|
r.codeIndexIn = &codeIndexIn
|
|
return r
|
|
}
|
|
|
|
func (r CodeAPIPostCodeIndexRequest) Execute() (*CodeIndexResult, *http.Response, error) {
|
|
return r.ApiService.PostCodeIndexExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostCodeIndex (re)indexes a repository for the caller's org, incrementally: files whose content hash is unchanged are skipped, so re-sending a whole tree is cheap.
|
|
|
|
(re)indexes a repository for the caller's org, incrementally: files whose
|
|
content hash is unchanged are skipped, so re-sending a whole tree is cheap.
|
|
Each file is parsed for symbols, split at AST boundaries and — when the
|
|
semantic tier is available — embedded, which is what makes it searchable across
|
|
all three retrieval tiers. Pass `prune` to also DELETE indexed files absent
|
|
from the request, which turns the call into a full sync; without it the call is
|
|
an upsert. The index is written to the caller org's own physically separate
|
|
database.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return CodeAPIPostCodeIndexRequest
|
|
*/
|
|
func (a *CodeAPIService) PostCodeIndex(ctx context.Context) CodeAPIPostCodeIndexRequest {
|
|
return CodeAPIPostCodeIndexRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return CodeIndexResult
|
|
func (a *CodeAPIService) PostCodeIndexExecute(r CodeAPIPostCodeIndexRequest) (*CodeIndexResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *CodeIndexResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CodeAPIService.PostCodeIndex")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/code/index"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.codeIndexIn == nil {
|
|
return localVarReturnValue, nil, reportError("codeIndexIn is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.codeIndexIn
|
|
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,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|