Documentation
¶
Overview ¶
Package client is the HTTP client for the AgentStore server.
Index ¶
- func SetCommitPageLimitForTest(n int)
- type Client
- func (c *Client) AddAdmin(username string) error
- func (c *Client) AddMember(username string) error
- func (c *Client) Authz() (server.AuthzResponse, error)
- func (c *Client) CreateRepo() error
- func (c *Client) DownloadObject(hash string) ([]byte, error)
- func (c *Client) Export() (server.ExportResponse, error)
- func (c *Client) GetAllCommits(since int64) ([]server.CommitJSON, error)
- func (c *Client) GetCommits(since int64) ([]server.CommitJSON, error)
- func (c *Client) GetHeads() ([]server.HeadJSON, error)
- func (c *Client) GetPrincipals() ([]server.PrincipalJSON, error)
- func (c *Client) Grant(principal, permission, path string) error
- func (c *Client) ListAdmins() ([]string, error)
- func (c *Client) ListDirectory() ([]server.DirectoryEntryResponse, error)
- func (c *Client) ListMembers() ([]server.PrincipalJSON, error)
- func (c *Client) LookupDirectory(username string) (server.DirectoryEntryResponse, error)
- func (c *Client) Mirror(req server.MirrorRequest) (server.MirrorResponse, error)
- func (c *Client) Permissions(path string) ([]server.PermissionEntry, error)
- func (c *Client) Push(req server.PushRequest) (PushResult, error)
- func (c *Client) Register(username, publicKey string) (string, error)
- func (c *Client) Rekey(publicKey string) error
- func (c *Client) RemoveMember(username string) error
- func (c *Client) RepoURL() string
- func (c *Client) Revoke(principal, path string) error
- func (c *Client) RevokeAdmin(username string) error
- func (c *Client) UploadObject(hash string, data []byte) error
- func (c *Client) WatchStream(ctx context.Context, pathPrefix, events string, cursor int64, ...) error
- func (c *Client) WhoAmI() (server.WhoAmIResponse, error)
- type Identity
- type PushResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCommitPageLimitForTest ¶
func SetCommitPageLimitForTest(n int)
SetCommitPageLimitForTest overrides the commit page size; for tests only.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with one AgentStore server.
func (*Client) Authz ¶
func (c *Client) Authz() (server.AuthzResponse, error)
Authz returns the caller's repo-wide authority.
func (*Client) CreateRepo ¶
CreateRepo sends POST /<repo> to create a new repo on the server.
func (*Client) DownloadObject ¶
DownloadObject fetches GET /<repo>/objects/<hash> and returns the raw bytes.
func (*Client) Export ¶
func (c *Client) Export() (server.ExportResponse, error)
Export fetches the repo's access control state (grants + roles) — admin only.
func (*Client) GetAllCommits ¶
func (c *Client) GetAllCommits(since int64) ([]server.CommitJSON, error)
GetAllCommits fetches every commit with seq > since, paginating past the per-request page limit. Used by clone, pull, and mirror so large repos are never silently truncated. Stubs (redacted commits) carry a seq too, so the cursor advances correctly across pages even when some commits are filtered.
func (*Client) GetCommits ¶
func (c *Client) GetCommits(since int64) ([]server.CommitJSON, error)
GetCommits fetches one page of GET /<repo>/commits?since=<seq> (up to commitPageLimit commits, oldest-first). Most callers want GetAllCommits.
func (*Client) GetPrincipals ¶
func (c *Client) GetPrincipals() ([]server.PrincipalJSON, error)
GetPrincipals fetches GET /<repo>/principals — the member roster.
func (*Client) ListAdmins ¶
ListAdmins returns the usernames of repo admins.
func (*Client) ListDirectory ¶
func (c *Client) ListDirectory() ([]server.DirectoryEntryResponse, error)
ListDirectory enumerates every principal registered in the remote's directory. Like LookupDirectory it hits the public directory plane, so it is unauthenticated (no repo or identity context required).
func (*Client) ListMembers ¶
func (c *Client) ListMembers() ([]server.PrincipalJSON, error)
ListMembers returns the repo roster.
func (*Client) LookupDirectory ¶
func (c *Client) LookupDirectory(username string) (server.DirectoryEntryResponse, error)
LookupDirectory resolves a username to its directory entry on the remote. The directory is public, so this is unauthenticated (the client may have no identity yet — this is how `bind` discovers an existing principal_id).
func (*Client) Mirror ¶
func (c *Client) Mirror(req server.MirrorRequest) (server.MirrorResponse, error)
Mirror uploads a full repo state to an empty target (bootstrap). The request is self-authenticated against the roster carried in the payload. It returns the signer's resulting identity on the target (principal_id preserved; username may be auto-renamed) plus any roster renames.
func (*Client) Permissions ¶
func (c *Client) Permissions(path string) ([]server.PermissionEntry, error)
Permissions lists the grants matching a path.
func (*Client) Push ¶
func (c *Client) Push(req server.PushRequest) (PushResult, error)
Push sends POST /<repo>/commits and returns the result.
func (*Client) Register ¶
Register sends POST /register with a username and public key (the open endpoint). Returns the server-assigned principal_id.
func (*Client) RemoveMember ¶
RemoveMember removes a member from the repo (admin only).
func (*Client) RevokeAdmin ¶
RevokeAdmin revokes the admin role (admin only).
func (*Client) UploadObject ¶
UploadObject sends PUT /<repo>/objects/<hash> with the raw content.
func (*Client) WatchStream ¶
func (c *Client) WatchStream(ctx context.Context, pathPrefix, events string, cursor int64, onEvent func(server.EventJSON)) error
WatchStream opens the watch WebSocket and delivers events to onEvent until the connection closes or ctx is cancelled. It is a single connection — callers add reconnect-with-cursor on top (see RunWatch in the cli package).
type Identity ¶
type Identity struct {
PrincipalID string
PrivateKey ed25519.PrivateKey
}
Identity signs requests. When nil, requests are sent unsigned (only valid for the open `register` endpoint).
type PushResult ¶
type PushResult struct {
ID string
Seq int64
Conflicts []server.ConflictFile // non-empty on OCC rejection
}
PushResult is the outcome of a Push call.