resources

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package resources owns the per-user inventory and management surface for reusable resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectorStatus added in v0.6.1

type ConnectorStatus struct {
	Readiness              string
	ReadinessDetail        string
	Online                 bool
	Lifecycle              string
	ProtocolMajor          int32
	ProtocolMinor          int32
	ArtifactVersion        string
	ArtifactDigest         string
	InterfaceHash          string
	ArtifactFreshness      string
	UpdateStatus           string
	LatestArtifactVersion  string
	LastHeartbeatAt        pgtype.Timestamptz
	ActiveProvenance       string
	ActiveObservationState string
	ObservedActiveDigest   string
	InventoryRevision      uint64
}

type Consumer

type Consumer struct {
	AgentID        uuid.UUID
	AgentName      string
	AgentSlug      string
	NeedType       string
	NeedSlug       string
	CanAccessAgent bool
}

Consumer identifies an agent need bound to a resource.

type Grant added in v0.6.1

type Grant struct {
	ID           uuid.UUID
	UserID       uuid.UUID
	Email        string
	DisplayName  string
	Capabilities []string
	CreatedAt    pgtype.Timestamptz
}

Grant is a user capability grant. Secret material and principal internals are deliberately absent from this operator-facing shape.

type Resource

type Resource struct {
	ID           uuid.UUID
	Type         string // connection | mcp_server | git_credential | connector | host | connector_target_group
	OwnerID      uuid.UUID
	OwnerName    string
	Slug         string
	Name         string
	DisplayName  string
	AuthMode     string
	Authorized   bool
	AgentCount   int32
	Capabilities []string
	CreatedAt    pgtype.Timestamptz
	HostID       uuid.UUID
	Connector    *ConnectorStatus
}

Resource is one resource available to the caller through ownership or a grant. It carries no secret material.

type Service

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

func New

func New(d *db.DB, connectors *connectorssvc.Service, logger *zap.Logger) *Service

func (*Service) Consumers

func (s *Service) Consumers(ctx context.Context, p authz.Principal, typ string, id uuid.UUID) ([]Consumer, error)

Consumers lists every agent need bound to a resource. Resource view capability is required; agent membership is not, because the grant controls visibility of this resource-level relationship.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, p authz.Principal, typ string, id uuid.UUID) error

Delete removes a resource. Connector rows are tombstoned for durable cleanup.

func (*Service) DeleteGrant added in v0.6.1

func (s *Service) DeleteGrant(ctx context.Context, p authz.Principal, typ string, id, userID uuid.UUID) error

DeleteGrant removes one user's grant without changing resource bindings.

func (*Service) List

func (s *Service) List(ctx context.Context, p authz.Principal) ([]Resource, error)

List returns resources available through ownership or a resource grant and exposes the caller's capabilities on each one.

func (*Service) ListGrants added in v0.6.1

func (s *Service) ListGrants(ctx context.Context, p authz.Principal, typ string, id uuid.UUID) ([]Grant, error)

ListGrants returns user grants only to resource managers.

func (*Service) Rename

func (s *Service) Rename(ctx context.Context, p authz.Principal, typ string, id uuid.UUID, displayName string) error

Rename updates a resource's non-unique user-controlled display name.

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, p authz.Principal, typ string, id uuid.UUID) error

Revoke clears stored credentials. Resource manage capability is required.

func (*Service) Transfer added in v0.6.1

func (s *Service) Transfer(ctx context.Context, p authz.Principal, typ string, id, newOwnerID uuid.UUID) error

Transfer moves ownership to an existing user and records the actor and both owners in the same transaction. Existing grants and agent bindings remain.

func (*Service) UpsertGrant added in v0.6.1

func (s *Service) UpsertGrant(ctx context.Context, p authz.Principal, typ string, id, userID uuid.UUID, capabilities []string) error

UpsertGrant creates or replaces one user's independent capabilities.

Jump to

Keyboard shortcuts

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