client

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

APIError represents an API error response.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsNotFound

func (e *APIError) IsNotFound() bool

IsNotFound returns true if the error is a 404.

type BlobResponse

type BlobResponse struct {
	Content  string `json:"content"`
	Path     string `json:"path"`
	Size     int64  `json:"size"`
	Language string `json:"language"`
	Binary   bool   `json:"binary"`
	Ref      string `json:"ref"`
}

BlobResponse represents file content.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for the Code Search API.

func New

func New(baseURL, authToken string) *Client

New creates a new API client. If authToken is non-empty, requests will include an Authorization: Bearer header.

func (*Client) FindReferences

func (c *Client) FindReferences(ctx context.Context, repoID int64, file string, line, column, limit int) (*FindReferencesResponse, error)

FindReferences finds all references to a symbol.

func (*Client) GetBranchesAndTags

func (c *Client) GetBranchesAndTags(ctx context.Context, repoID int64) (*RefsResponse, error)

GetBranchesAndTags returns branches and tags for a repository.

func (*Client) GetFileContent

func (c *Client) GetFileContent(ctx context.Context, repoID int64, path, ref string) (*BlobResponse, error)

GetFileContent returns the content of a file.

func (*Client) GetFileTree

func (c *Client) GetFileTree(ctx context.Context, repoID int64, path, ref string) (*TreeResponse, error)

GetFileTree returns directory contents for a repository.

func (*Client) GoToDefinition

func (c *Client) GoToDefinition(ctx context.Context, repoID int64, file string, line, column int) (*GoToDefinitionResponse, error)

GoToDefinition finds the definition of a symbol.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, params ListReposParams) (*ListReposResponse, error)

ListRepos lists indexed repositories.

func (*Client) Search

func (c *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)

Search performs a code search.

func (*Client) SearchSymbols

func (c *Client) SearchSymbols(ctx context.Context, repoID int64, query string, limit int) (*SearchSymbolsResponse, error)

SearchSymbols searches for symbols in a repository.

type FindReferencesResponse

type FindReferencesResponse struct {
	Found      bool         `json:"found"`
	Symbol     string       `json:"symbol,omitempty"`
	Definition *Occurrence  `json:"definition,omitempty"`
	References []Occurrence `json:"references"`
	TotalCount int          `json:"totalCount"`
}

FindReferencesResponse represents the find-references API response.

type GoToDefinitionResponse

type GoToDefinitionResponse struct {
	Found      bool        `json:"found"`
	Symbol     string      `json:"symbol,omitempty"`
	Definition *Occurrence `json:"definition,omitempty"`
	Info       *SymbolInfo `json:"info,omitempty"`
	External   bool        `json:"external"`
}

GoToDefinitionResponse represents the go-to-definition API response.

type ListReposParams

type ListReposParams struct {
	Search string
	Status string
	Limit  int
	Offset int
}

ListReposParams contains parameters for listing repos.

type ListReposResponse

type ListReposResponse struct {
	Repos      []Repository `json:"repos"`
	TotalCount int          `json:"total_count"`
	Limit      int          `json:"limit"`
	Offset     int          `json:"offset"`
	HasMore    bool         `json:"has_more"`
}

ListReposResponse represents the list repos response.

type Occurrence

type Occurrence struct {
	Symbol    string `json:"symbol"`
	FilePath  string `json:"filePath"`
	StartLine int    `json:"startLine"`
	StartCol  int    `json:"startCol"`
	EndLine   int    `json:"endLine"`
	EndCol    int    `json:"endCol"`
	Context   string `json:"context,omitempty"`
}

Occurrence represents a SCIP occurrence.

type RefsResponse

type RefsResponse struct {
	Branches      []string `json:"branches"`
	Tags          []string `json:"tags"`
	DefaultBranch string   `json:"default_branch"`
}

RefsResponse represents branches and tags.

type Repository

type Repository struct {
	ID            int64    `json:"id"`
	Name          string   `json:"name"`
	CloneURL      string   `json:"clone_url"`
	DefaultBranch string   `json:"default_branch"`
	Branches      []string `json:"branches"`
	Status        string   `json:"status"`
	LastIndexed   string   `json:"last_indexed,omitempty"`
	Excluded      bool     `json:"excluded"`
	Deleted       bool     `json:"deleted"`
}

Repository represents a repository.

type ResultContext

type ResultContext struct {
	Before []string `json:"before"`
	After  []string `json:"after"`
}

ResultContext represents lines around a match.

type SearchRequest

type SearchRequest struct {
	Query         string   `json:"query"`
	IsRegex       bool     `json:"is_regex,omitempty"`
	CaseSensitive bool     `json:"case_sensitive,omitempty"`
	Repos         []string `json:"repos,omitempty"`
	Languages     []string `json:"languages,omitempty"`
	FilePatterns  []string `json:"file_patterns,omitempty"`
	Limit         int      `json:"limit,omitempty"`
	ContextLines  int      `json:"context_lines,omitempty"`
}

SearchRequest represents a search request.

type SearchResponse

type SearchResponse struct {
	Results    []SearchResult `json:"results"`
	TotalCount int            `json:"total_count"`
	Truncated  bool           `json:"truncated"`
	Duration   string         `json:"duration"`
}

SearchResponse represents the search API response.

type SearchResult

type SearchResult struct {
	Repo       string        `json:"repo"`
	File       string        `json:"file"`
	Line       int           `json:"line"`
	Column     int           `json:"column"`
	Content    string        `json:"content"`
	Context    ResultContext `json:"context"`
	Language   string        `json:"language"`
	MatchStart int           `json:"match_start"`
	MatchEnd   int           `json:"match_end"`
}

SearchResult represents a single search result.

type SearchSymbolsResponse

type SearchSymbolsResponse struct {
	Results []SymbolSearchResult `json:"results"`
	Count   int                  `json:"count"`
}

SearchSymbolsResponse represents the search symbols API response.

type SymbolInfo

type SymbolInfo struct {
	Symbol        string `json:"symbol"`
	Documentation string `json:"documentation,omitempty"`
	DisplayName   string `json:"displayName,omitempty"`
}

SymbolInfo contains metadata about a symbol.

type SymbolSearchResult

type SymbolSearchResult struct {
	Symbol        string `json:"symbol"`
	DisplayName   string `json:"displayName,omitempty"`
	FilePath      string `json:"filePath"`
	Line          int    `json:"line"`
	Documentation string `json:"documentation,omitempty"`
}

SymbolSearchResult represents a symbol search result.

type TreeEntry

type TreeEntry struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Path     string `json:"path"`
	Size     int64  `json:"size,omitempty"`
	Language string `json:"language,omitempty"`
}

TreeEntry represents a file or directory in a tree listing.

type TreeResponse

type TreeResponse struct {
	Entries []TreeEntry `json:"entries"`
	Path    string      `json:"path"`
	Ref     string      `json:"ref"`
}

TreeResponse represents the tree API response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL