Documentation
¶
Overview ¶
Package agents handles agent identity registration, token issuance, and lifecycle management.
Index ¶
- type Agent
- type IssueTokenRequest
- type IssueTokenResponse
- type RegisterRequest
- type RegisterResponse
- type Service
- func (s *Service) Delete(workspaceID, registrationID string) error
- func (s *Service) GetByName(workspaceID, name string) (*Agent, error)
- func (s *Service) List(workspaceID, projectID string) ([]Agent, error)
- func (s *Service) Register(req RegisterRequest) (*RegisterResponse, error)
- func (s *Service) TokenIssue(workspaceID, registrationID string, req IssueTokenRequest) (*IssueTokenResponse, error)
- func (s *Service) TokenList(workspaceID, registrationID string) ([]Token, error)
- func (s *Service) TokenRevoke(workspaceID, registrationID string, tokenID string) error
- func (s *Service) TokenRevokeAll(workspaceID, registrationID string) error
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
WorkspaceID string `json:"workspace_id"`
ProjectID *string `json:"project_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
TokenCount int `json:"token_count"`
LastUsed *time.Time `json:"last_used"`
}
Agent represents a registered agent identity.
type IssueTokenRequest ¶
type IssueTokenRequest struct {
Environment string `json:"environment,omitempty"`
Label string `json:"label,omitempty"`
ExpiresIn string `json:"expires_in,omitempty"`
}
IssueTokenRequest holds data to issue a new token.
type IssueTokenResponse ¶
type IssueTokenResponse struct {
TokenID string `json:"token_id"`
Token string `json:"token"` // The cleartext token
Label string `json:"label,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
IssueTokenResponse is returned when issuing a new token.
type RegisterRequest ¶
type RegisterRequest struct {
Name string `json:"name"`
WorkspaceID string `json:"-"` // used for routing, not sent in body
ProjectID string `json:"project_id,omitempty"`
Environment string `json:"environment,omitempty"` // development, staging, production
Label string `json:"label,omitempty"`
ExpiresIn string `json:"expires_in,omitempty"` // e.g., "30d"
}
RegisterRequest holds data to register a new agent.
type RegisterResponse ¶
type RegisterResponse struct {
Agent Agent `json:"agent"`
Token string `json:"token"` // The cleartext token (only shown once)
Label string `json:"label,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
RegisterResponse is returned when registering a new agent (contains the cleartext token).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides methods to interact with agent resources.
func NewService ¶
func (*Service) Delete ¶
Delete revokes all tokens for an agent then deletes the registration. This first revokes all active tokens then issues a DELETE to the workspace agent route.
func (*Service) GetByName ¶
GetByName returns an agent by its exact name within the given workspace.
func (*Service) List ¶
List returns agents scoped to the given workspace (or project if projectID is non-empty).
func (*Service) Register ¶
func (s *Service) Register(req RegisterRequest) (*RegisterResponse, error)
Register registers a new agent and issues its first token. req.WorkspaceID is required; set req.ProjectID to scope the agent to a project.
func (*Service) TokenIssue ¶
func (s *Service) TokenIssue(workspaceID, registrationID string, req IssueTokenRequest) (*IssueTokenResponse, error)
TokenIssue issues a new token for an existing agent.
func (*Service) TokenRevoke ¶
TokenRevoke revokes a single token.
func (*Service) TokenRevokeAll ¶
TokenRevokeAll revokes all active tokens for an agent by listing then deleting each.
type Token ¶
type Token struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
Label string `json:"label"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
LastUsed *time.Time `json:"last_used,omitempty"`
Status string `json:"status"` // e.g., "active", "revoked", "expired"
}
Token represents a token issued to an agent.