Documentation
¶
Index ¶
- type AddRepositoryRequest
- type Client
- func (c *Client) AddRepository(ctx context.Context, req *AddRepositoryRequest) (*Repository, error)
- func (c *Client) ExcludeRepository(ctx context.Context, id int64) error
- func (c *Client) FindFiles(ctx context.Context, req *FindFilesRequest) (*FindFilesResponse, error)
- func (c *Client) FindRefs(ctx context.Context, req *FindRefsRequest) ([]Reference, error)
- func (c *Client) FindSymbols(ctx context.Context, req *FindSymbolsRequest) ([]Symbol, error)
- func (c *Client) GetReposStatus(ctx context.Context) (*ReposStatus, error)
- func (c *Client) GetRepository(ctx context.Context, id int64) (*Repository, error)
- func (c *Client) IncludeRepository(ctx context.Context, id int64) error
- func (c *Client) ListRepositories(ctx context.Context, connectionID *int64) (*ListRepositoriesResponse, error)
- func (c *Client) RemoveRepository(ctx context.Context, id int64) error
- func (c *Client) ReplaceExecute(ctx context.Context, req *ReplaceExecuteRequest) (*ReplaceExecuteResponse, error)
- func (c *Client) ReplacePreview(ctx context.Context, req *ReplacePreviewRequest) (*ReplacePreviewResponse, error)
- func (c *Client) RestoreRepository(ctx context.Context, id int64) error
- func (c *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
- func (c *Client) SearchStream(ctx context.Context, req *SearchRequest, callback SearchStreamCallback) error
- func (c *Client) SyncAllRepositories(ctx context.Context) error
- func (c *Client) SyncRepository(ctx context.Context, id int64) error
- type ClientOption
- type FileResult
- type FindFilesRequest
- type FindFilesResponse
- type FindRefsRequest
- type FindSymbolsRequest
- type LineReader
- type ListRepositoriesResponse
- type Reference
- type ReplaceExecuteRequest
- type ReplaceExecuteResponse
- type ReplaceMatch
- type ReplacePreviewMatch
- type ReplacePreviewRequest
- type ReplacePreviewResponse
- type ReposStatus
- type Repository
- type ResultContext
- type SearchRequest
- type SearchResponse
- type SearchResult
- type SearchStreamCallback
- type SearchStreamEvent
- type Symbol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRepositoryRequest ¶
type AddRepositoryRequest struct {
ConnectionID int64 `json:"connection_id"`
Name string `json:"name"`
CloneURL string `json:"clone_url"`
DefaultBranch string `json:"default_branch"`
Branches []string `json:"branches,omitempty"`
}
AddRepositoryRequest represents a request to add a repository.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the API client for code-search.
func New ¶
func New(baseURL, token string, opts ...ClientOption) *Client
New creates a new API client.
func (*Client) AddRepository ¶
func (c *Client) AddRepository( ctx context.Context, req *AddRepositoryRequest, ) (*Repository, error)
AddRepository adds a new repository.
func (*Client) ExcludeRepository ¶
ExcludeRepository excludes a repository from sync and indexing.
func (*Client) FindFiles ¶
func (c *Client) FindFiles(ctx context.Context, req *FindFilesRequest) (*FindFilesResponse, error)
FindFiles finds files matching a pattern using the search API with file: filter.
func (*Client) FindSymbols ¶
FindSymbols finds symbol definitions.
func (*Client) GetReposStatus ¶
func (c *Client) GetReposStatus(ctx context.Context) (*ReposStatus, error)
GetReposStatus gets the repos readonly status from the server.
func (*Client) GetRepository ¶
GetRepository gets a specific repository by ID.
func (*Client) IncludeRepository ¶
IncludeRepository includes a previously excluded repository.
func (*Client) ListRepositories ¶
func (c *Client) ListRepositories( ctx context.Context, connectionID *int64, ) (*ListRepositoriesResponse, error)
ListRepositories lists all indexed repositories.
func (*Client) RemoveRepository ¶
RemoveRepository removes a repository by ID.
func (*Client) ReplaceExecute ¶
func (c *Client) ReplaceExecute( ctx context.Context, req *ReplaceExecuteRequest, ) (*ReplaceExecuteResponse, error)
ReplaceExecute executes replacements across repositories.
func (*Client) ReplacePreview ¶
func (c *Client) ReplacePreview( ctx context.Context, req *ReplacePreviewRequest, ) (*ReplacePreviewResponse, error)
ReplacePreview previews what would be replaced without making changes.
func (*Client) RestoreRepository ¶
RestoreRepository restores a previously deleted repository.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
Search performs a code search.
func (*Client) SearchStream ¶
func (c *Client) SearchStream( ctx context.Context, req *SearchRequest, callback SearchStreamCallback, ) error
SearchStream performs a streaming code search and calls the callback for each event.
func (*Client) SyncAllRepositories ¶
SyncAllRepositories triggers a sync for all repositories via scheduler.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a functional option for Client.
func WithAuthToken ¶
func WithAuthToken(token string) ClientOption
WithAuthToken sets the authentication token (JWT or API token) for Bearer auth. Takes priority over IAP authentication when both are set.
func WithIAPClientID ¶
func WithIAPClientID(clientID string) ClientOption
WithIAPClientID sets the IAP OAuth client ID for servers behind Google IAP. When set, the client will fetch a gcloud identity token and include it in requests.
type FileResult ¶
FileResult represents a file search result.
type FindFilesRequest ¶
type FindFilesRequest struct {
Pattern string `json:"pattern"`
IsRegex bool `json:"is_regex,omitempty"`
Repo string `json:"repo,omitempty"`
Limit int `json:"limit,omitempty"`
}
FindFilesRequest represents a find files request.
type FindFilesResponse ¶
type FindFilesResponse struct {
Files []FileResult `json:"files"`
Total int `json:"total"`
}
FindFilesResponse represents the find files response.
type FindRefsRequest ¶
type FindRefsRequest struct {
Symbol string `json:"symbol"`
Repos []string `json:"repos,omitempty"`
Language string `json:"language,omitempty"`
Limit int `json:"limit,omitempty"`
}
FindRefsRequest represents a find references request.
type FindSymbolsRequest ¶
type FindSymbolsRequest struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Language string `json:"language,omitempty"`
Repos []string `json:"repos,omitempty"`
Limit int `json:"limit,omitempty"`
}
FindSymbolsRequest represents a find symbols request.
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
LineReader is a simple line reader for SSE parsing.
func NewLineReader ¶
func NewLineReader(r io.Reader) *LineReader
NewLineReader creates a new LineReader.
func (*LineReader) ReadLine ¶
func (lr *LineReader) ReadLine() (string, error)
ReadLine reads a single line from the reader.
type ListRepositoriesResponse ¶
type ListRepositoriesResponse struct {
Repos []Repository `json:"repos"`
TotalCount int `json:"total_count"`
}
ListRepositoriesResponse represents the list repositories response.
type Reference ¶
type Reference struct {
Repo string `json:"repo"`
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Context string `json:"context"`
}
Reference represents a symbol reference.
type ReplaceExecuteRequest ¶
type ReplaceExecuteRequest struct {
SearchPattern string `json:"search_pattern"`
ReplaceWith string `json:"replace_with"`
IsRegex bool `json:"is_regex"`
CaseSensitive bool `json:"case_sensitive"`
FilePatterns []string `json:"file_patterns,omitempty"`
// Matches from preview (required) - MR is always created
Matches []ReplaceMatch `json:"matches"`
BranchName string `json:"branch_name,omitempty"`
MRTitle string `json:"mr_title,omitempty"`
MRDescription string `json:"mr_description,omitempty"`
// User-provided tokens for authentication (map of connection_id or "*" for all -> token)
UserTokens map[string]string `json:"user_tokens,omitempty"`
}
ReplaceExecuteRequest represents a request to execute replacements.
type ReplaceExecuteResponse ¶
type ReplaceExecuteResponse struct {
JobID string `json:"job_id"`
Status string `json:"status"`
Message string `json:"message"`
}
ReplaceExecuteResponse represents the replace execute response.
type ReplaceMatch ¶
type ReplaceMatch struct {
RepositoryID int64 `json:"repository_id"`
RepositoryName string `json:"repository_name"`
FilePath string `json:"file_path"`
}
ReplaceMatch represents a pre-computed match from preview.
type ReplacePreviewMatch ¶
type ReplacePreviewMatch struct {
RepositoryID int64 `json:"repository_id"`
Repo string `json:"repo"`
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Content string `json:"content"`
MatchStart int `json:"match_start"`
MatchEnd int `json:"match_end"`
Context ResultContext `json:"context"`
}
ReplacePreviewMatch represents a potential replacement.
type ReplacePreviewRequest ¶
type ReplacePreviewRequest struct {
SearchPattern string `json:"search_pattern"`
ReplaceWith string `json:"replace_with"`
IsRegex bool `json:"is_regex"`
CaseSensitive bool `json:"case_sensitive"`
FilePatterns []string `json:"file_patterns,omitempty"`
Repos []string `json:"repos,omitempty"`
Languages []string `json:"languages,omitempty"`
Limit int `json:"limit,omitempty"`
ContextLines int `json:"context_lines,omitempty"`
}
ReplacePreviewRequest represents a request to preview replacements.
type ReplacePreviewResponse ¶
type ReplacePreviewResponse struct {
Matches []ReplacePreviewMatch `json:"matches"`
TotalCount int `json:"total_count"`
Duration string `json:"duration"`
}
ReplacePreviewResponse represents the replace preview response.
type ReposStatus ¶
type ReposStatus struct {
ReadOnly bool `json:"readonly"`
}
ReposStatus represents the repos status response.
type Repository ¶
type Repository struct {
ID int64 `json:"id"`
Name string `json:"name"`
CloneURL string `json:"clone_url"`
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 ¶
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 (matches API response).
type SearchStreamCallback ¶
type SearchStreamCallback func(event *SearchStreamEvent) error
SearchStreamCallback is called for each event in the search stream.
type SearchStreamEvent ¶
type SearchStreamEvent struct {
Type string `json:"type"` // "result", "progress", "done", "error"
Result *SearchResult `json:"result,omitempty"`
TotalCount int `json:"total_count,omitempty"`
Duration string `json:"duration,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Progress int `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
}
SearchStreamEvent represents an event from the search stream.
type Symbol ¶
type Symbol struct {
Name string `json:"name"`
Kind string `json:"kind"`
Repo string `json:"repo"`
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Signature string `json:"signature,omitempty"`
Language string `json:"language"`
}
Symbol represents a code symbol.