Documentation
¶
Overview ¶
Package templates provides template client services for the remote-signer.
Index ¶
- type API
- type BudgetConfig
- type CreateRequest
- type InstantiateRequest
- type InstantiateResponse
- type ListFilter
- type ListResponse
- type RevokeInstanceResponse
- type ScheduleConfig
- type Service
- func (s *Service) Create(ctx context.Context, req *CreateRequest) (*Template, error)
- func (s *Service) Delete(ctx context.Context, templateID string) error
- func (s *Service) Get(ctx context.Context, templateID string) (*Template, error)
- func (s *Service) Instantiate(ctx context.Context, templateID string, req *InstantiateRequest) (*InstantiateResponse, error)
- func (s *Service) List(ctx context.Context, filter *ListFilter) (*ListResponse, error)
- func (s *Service) RevokeInstance(ctx context.Context, ruleID string) (*RevokeInstanceResponse, error)
- func (s *Service) Update(ctx context.Context, templateID string, req *UpdateRequest) (*Template, error)
- type Template
- type TemplateVariable
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
List(ctx context.Context, filter *ListFilter) (*ListResponse, error)
Get(ctx context.Context, templateID string) (*Template, error)
Create(ctx context.Context, req *CreateRequest) (*Template, error)
Update(ctx context.Context, templateID string, req *UpdateRequest) (*Template, error)
Delete(ctx context.Context, templateID string) error
Instantiate(ctx context.Context, templateID string, req *InstantiateRequest) (*InstantiateResponse, error)
RevokeInstance(ctx context.Context, ruleID string) (*RevokeInstanceResponse, error)
}
API defines the template service interface.
type BudgetConfig ¶
type BudgetConfig struct {
MaxTotal string `json:"max_total"`
MaxPerTx string `json:"max_per_tx"`
MaxTxCount int `json:"max_tx_count,omitempty"`
AlertPct int `json:"alert_pct,omitempty"`
}
BudgetConfig defines budget limits for an instance.
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Mode string `json:"mode"`
Variables []TemplateVariable `json:"variables,omitempty"`
Config map[string]interface{} `json:"config"`
BudgetMetering map[string]interface{} `json:"budget_metering,omitempty"`
TestVariables map[string]string `json:"test_variables,omitempty"`
Enabled bool `json:"enabled"`
}
CreateRequest represents a request to create a new template.
type InstantiateRequest ¶
type InstantiateRequest struct {
TemplateName string `json:"template_name,omitempty"`
Name string `json:"name,omitempty"`
Variables map[string]string `json:"variables"`
ChainType *string `json:"chain_type,omitempty"`
ChainID *string `json:"chain_id,omitempty"`
APIKeyID *string `json:"api_key_id,omitempty"`
SignerAddress *string `json:"signer_address,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
ExpiresIn *string `json:"expires_in,omitempty"`
Budget *BudgetConfig `json:"budget,omitempty"`
Schedule *ScheduleConfig `json:"schedule,omitempty"`
}
InstantiateRequest represents a request to create a rule instance from a template.
type InstantiateResponse ¶
type InstantiateResponse struct {
Rule json.RawMessage `json:"rule"`
Budget json.RawMessage `json:"budget,omitempty"`
}
InstantiateResponse represents the response from creating a rule instance.
type ListFilter ¶
ListFilter contains filter options for listing templates.
type ListResponse ¶
ListResponse represents the response from listing templates.
type RevokeInstanceResponse ¶
RevokeInstanceResponse represents the response from revoking an instance.
type ScheduleConfig ¶
type ScheduleConfig struct {
Period string `json:"period"`
StartAt *time.Time `json:"start_at,omitempty"`
}
ScheduleConfig defines periodic budget renewal.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles template operations.
func NewService ¶
NewService creates a new template service.
func (*Service) Instantiate ¶
func (s *Service) Instantiate(ctx context.Context, templateID string, req *InstantiateRequest) (*InstantiateResponse, error)
Instantiate creates a rule instance from a template (admin only).
func (*Service) List ¶
func (s *Service) List(ctx context.Context, filter *ListFilter) (*ListResponse, error)
List lists rule templates with optional filters.
func (*Service) RevokeInstance ¶
func (s *Service) RevokeInstance(ctx context.Context, ruleID string) (*RevokeInstanceResponse, error)
RevokeInstance revokes (disables) a rule instance created from a template (admin only).
type Template ¶
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Mode string `json:"mode"`
Source string `json:"source"`
Variables []TemplateVariable `json:"variables,omitempty"`
Config json.RawMessage `json:"config,omitempty"`
BudgetMetering json.RawMessage `json:"budget_metering,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Template represents a rule template.