api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package api provides the API client for the search server Per AI.md PART 36: Admin API methods

Index

Constants

This section is empty.

Variables

View Source
var ProjectName = "search"

ProjectName is set at build time - used for User-Agent

View Source
var Version = "dev"

Version is set at build time

Functions

This section is empty.

Types

type AutodiscoverResponse

type AutodiscoverResponse struct {
	Server struct {
		Name     string `json:"name"`
		Version  string `json:"version"`
		URL      string `json:"url"`
		Features struct {
			Auth     bool `json:"auth"`
			Search   bool `json:"search"`
			Register bool `json:"register"`
		} `json:"features"`
	} `json:"server"`
	Cluster struct {
		Primary string   `json:"primary"`
		Nodes   []string `json:"nodes"`
	} `json:"cluster"`
	API struct {
		Version  string `json:"version"`
		BasePath string `json:"base_path"`
	} `json:"api"`
}

AutodiscoverResponse represents /api/autodiscover response Per AI.md PART 36 line 38077-38157: Autodiscover endpoint

type BuildInfo

type BuildInfo struct {
	CommitID  string `json:"commit_id"`
	BuildDate string `json:"build_date"`
}

BuildInfo represents build information

type Client

type Client struct {
	BaseURL      string
	Token        string
	UserContext  string   // Per AI.md PART 36: --user flag for user/org context
	ClusterNodes []string // Per AI.md PART 36: cluster nodes for failover
	HTTPClient   *http.Client
	// contains filtered or unexported fields
}

Client is the API client for the search server Per AI.md PART 36 line 42791-42818: Cluster failover support

func NewClient

func NewClient(baseURL, token string, timeout int) *Client

NewClient creates a new API client

func (*Client) AdminAddOrgMember

func (c *Client) AdminAddOrgMember(orgname, username, role string) error

AdminAddOrgMember adds a member to organization

func (*Client) AdminCreateOrg

func (c *Client) AdminCreateOrg(orgname, displayName, description string) (interface{}, error)

AdminCreateOrg creates a new organization

func (*Client) AdminCreateToken

func (c *Client) AdminCreateToken(name, expires, scopes string) (interface{}, error)

AdminCreateToken creates a new API token

func (*Client) AdminCreateUser

func (c *Client) AdminCreateUser(username, email, role string) (interface{}, error)

AdminCreateUser creates a new user

func (*Client) AdminDeleteOrg

func (c *Client) AdminDeleteOrg(orgname string) error

AdminDeleteOrg deletes an organization

func (*Client) AdminDeleteUser

func (c *Client) AdminDeleteUser(username string) error

AdminDeleteUser deletes a user

func (*Client) AdminDisableUser2FA

func (c *Client) AdminDisableUser2FA(username string) error

AdminDisableUser2FA disables 2FA for user

func (*Client) AdminGetConfig

func (c *Client) AdminGetConfig(key string) (interface{}, error)

AdminGetConfig gets configuration value

func (*Client) AdminGetOrg

func (c *Client) AdminGetOrg(orgname string) (interface{}, error)

AdminGetOrg gets organization details

func (*Client) AdminGetStatsOverview

func (c *Client) AdminGetStatsOverview() (interface{}, error)

AdminGetStatsOverview gets general server statistics

func (*Client) AdminGetStatsPerformance

func (c *Client) AdminGetStatsPerformance() (interface{}, error)

AdminGetStatsPerformance gets performance metrics

func (*Client) AdminGetStatsStorage

func (c *Client) AdminGetStatsStorage() (interface{}, error)

AdminGetStatsStorage gets storage usage statistics

func (*Client) AdminGetStatsUsers

func (c *Client) AdminGetStatsUsers() (interface{}, error)

AdminGetStatsUsers gets user statistics

func (*Client) AdminGetTokenInfo

func (c *Client) AdminGetTokenInfo(tokenID string) (interface{}, error)

AdminGetTokenInfo gets token details

func (*Client) AdminGetUser

func (c *Client) AdminGetUser(username string) (interface{}, error)

AdminGetUser gets user details

func (*Client) AdminInviteServerAdmin

func (c *Client) AdminInviteServerAdmin(username, email string) error

AdminInviteServerAdmin invites a new server admin

func (*Client) AdminListConfig

func (c *Client) AdminListConfig(category string) (interface{}, error)

AdminListConfig lists all configuration keys

func (*Client) AdminListOrgMembers

func (c *Client) AdminListOrgMembers(orgname, role string) (interface{}, error)

AdminListOrgMembers lists organization members

func (*Client) AdminListOrgs

func (c *Client) AdminListOrgs(limit, offset int) (interface{}, error)

AdminListOrgs lists all organizations

func (*Client) AdminListServerAdmins

func (c *Client) AdminListServerAdmins() (interface{}, error)

AdminListServerAdmins lists all server admins

func (*Client) AdminListTokens

func (c *Client) AdminListTokens(limit int, user string) (interface{}, error)

AdminListTokens lists all tokens

func (*Client) AdminListUsers

func (c *Client) AdminListUsers(limit, offset int, status string) (interface{}, error)

AdminListUsers lists all users

func (*Client) AdminRemoveOrgMember

func (c *Client) AdminRemoveOrgMember(orgname, username string) error

AdminRemoveOrgMember removes a member from organization

func (*Client) AdminRemoveServerAdmin

func (c *Client) AdminRemoveServerAdmin(username string) error

AdminRemoveServerAdmin removes a server admin

func (*Client) AdminResetConfig

func (c *Client) AdminResetConfig(key string) error

AdminResetConfig resets configuration to default

func (*Client) AdminResetServerAdminPassword

func (c *Client) AdminResetServerAdminPassword(username string) error

AdminResetServerAdminPassword sends password reset to admin

func (*Client) AdminResetUserPassword

func (c *Client) AdminResetUserPassword(username string) error

AdminResetUserPassword sends password reset email

func (*Client) AdminRevokeToken

func (c *Client) AdminRevokeToken(tokenID string) error

AdminRevokeToken revokes a token

func (*Client) AdminSetConfig

func (c *Client) AdminSetConfig(key, value string, reload bool) error

AdminSetConfig sets configuration value

func (*Client) AdminSuspendUser

func (c *Client) AdminSuspendUser(username string) error

AdminSuspendUser suspends a user

func (*Client) AdminUnsuspendUser

func (c *Client) AdminUnsuspendUser(username string) error

AdminUnsuspendUser unsuspends a user

func (*Client) Autodiscover

func (c *Client) Autodiscover() (*AutodiscoverResponse, error)

Autodiscover fetches server settings from /api/autodiscover Per AI.md PART 36 line 38077-38157: Non-versioned autodiscover endpoint

func (*Client) GetClusterNodes

func (c *Client) GetClusterNodes() []string

GetClusterNodes returns current cluster nodes

func (*Client) GetVersion

func (c *Client) GetVersion() (string, error)

GetVersion returns server version info

func (*Client) Health

func (c *Client) Health() (*HealthResponse, error)

Health checks server health

func (*Client) Search

func (c *Client) Search(query string, page, perPage int) (*SearchResponse, error)

Search performs a search query

func (*Client) SetClusterNodes

func (c *Client) SetClusterNodes(nodes []string)

SetClusterNodes sets the cluster nodes for failover Per AI.md PART 36 line 42791-42818: Cluster failover

func (*Client) SetUserContext

func (c *Client) SetUserContext(ctx string)

SetUserContext sets the user or org context for API requests Per AI.md PART 36 line 41490-41498: --user flag for user/org context @name = force user context +name = force org context name = auto-detect

type ClusterInfo

type ClusterInfo struct {
	Enabled bool   `json:"enabled"`
	Status  string `json:"status"`
	Nodes   int    `json:"nodes"`
}

ClusterInfo represents cluster information

type HealthResponse

type HealthResponse struct {
	Status         string            `json:"status"`
	Version        string            `json:"version,omitempty"`
	GoVersion      string            `json:"go_version,omitempty"`
	Mode           string            `json:"mode,omitempty"`
	Uptime         string            `json:"uptime,omitempty"`
	Timestamp      string            `json:"timestamp,omitempty"`
	Build          *BuildInfo        `json:"build,omitempty"`
	Node           *NodeInfo         `json:"node,omitempty"`
	Cluster        *ClusterInfo      `json:"cluster,omitempty"`
	Features       map[string]bool   `json:"features,omitempty"`
	Checks         map[string]string `json:"checks,omitempty"`
	Stats          *HealthStats      `json:"stats,omitempty"`
	PendingRestart bool              `json:"pending_restart,omitempty"`
	RestartReason  []string          `json:"restart_reason,omitempty"`
}

HealthResponse represents health check response

type HealthStats

type HealthStats struct {
	RequestsTotal     int64 `json:"requests_total"`
	Requests24h       int64 `json:"requests_24h"`
	ActiveConnections int   `json:"active_connections"`
}

HealthStats represents health statistics

type NodeInfo

type NodeInfo struct {
	ID       string `json:"id"`
	Hostname string `json:"hostname"`
}

NodeInfo represents node information

type SearchPagination

type SearchPagination struct {
	Page  int `json:"page"`
	Limit int `json:"limit"`
	Total int `json:"total"`
	Pages int `json:"pages"`
}

SearchPagination represents pagination info per AI.md PART 14

type SearchResponse

type SearchResponse struct {
	Query      string           `json:"query"`
	Category   string           `json:"category"`
	Results    []SearchResult   `json:"results"`
	Pagination SearchPagination `json:"pagination"`
	SearchTime float64          `json:"search_time_ms"`
	Engines    []string         `json:"engines_used"`
}

SearchResponse represents the API search response per AI.md PART 14

type SearchResult

type SearchResult struct {
	Title       string  `json:"title"`
	URL         string  `json:"url"`
	Description string  `json:"description"`
	Engine      string  `json:"engine"`
	Score       float64 `json:"score"`
	Category    string  `json:"category"`
	Thumbnail   string  `json:"thumbnail,omitempty"`
	Domain      string  `json:"domain,omitempty"`
}

SearchResult represents a search result

Jump to

Keyboard shortcuts

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